Materialized view vs. (logical) view

TopicViewMaterialized View
What it isA stored query; results are computed each time you query itA precomputed table of the query’s results, stored on disk
PerformanceSame as running the underlying SELECT every timeFast to read (results already computed)
FreshnessAlways current (reads base tables live)Can be stale until it’s refreshed (on a schedule or on demand)
Storage cost~None (just metadata)Consumes storage (it’s physically materialized)
MaintenanceNo refresh neededNeeds refresh/maintenance; refresh costs compute
Good forConvenience, security (row/column masking via views), reuse of logicDashboards/BI and heavy aggregates that repeat often
Failure surfaceSame as base queryAdds refresh jobs, dependencies, and staleness management

Databricks-specific notes (Unity Catalog / DBSQL)

  • A materialized view (MV) is stored as a Delta table and maintained by Databricks; you can schedule it or refresh manually.
  • Typical syntax: -- Logical view CREATE OR REPLACE VIEW prod.dw.v_sales AS SELECT d.date_key, SUM(amount) AS revenue FROM prod.dw.fact_sales f JOIN prod.dw.dim_date d USING(date_key) GROUP BY d.date_key; -- Materialized view (precompute + keep it fresh) CREATE OR REPLACE MATERIALIZED VIEW prod.dw.mv_daily_sales SCHEDULE EVERY 15 MINUTES AS SELECT date_key, SUM(amount) AS revenue FROM prod.dw.fact_sales GROUP BY date_key; -- On-demand refresh (if needed) REFRESH MATERIALIZED VIEW prod.dw.mv_daily_sales;
  • Privileges: readers need SELECT on the view/MV; to rebuild an MV you also need the REFRESH privilege (and of course USE CATALOG/SCHEMA on the container).
  • Trade-off: MVs buy latency at the cost of storage + refresh compute and possible staleness. Views are always up-to-date but can be slower.

Quick “when to use which”

  • Use a view when you want a reusable, secure, always-fresh SQL abstraction.
  • Use a materialized view when many users hit the same heavy query (e.g., daily revenue by product) and you want sub-second BI with predictable cost.

Related Posts

Z-ORDER in Databricks: Magic or Myth?

When it helps, when it hurts, how to pick columns, and what KPIs to measure. Introduction: Why the Hype Around Z-ORDER? If you’ve spent time in Databricks,…

Read More

Taming Small Files in Delta Lake

Optimal file sizes, compaction strategies, and how to keep your Delta tables lightning-fast Why Small Files Are a Big Problem Delta Lake is powerful, but it inherits…

Read More

Databrick Serverless compute plane networking

Here’s a simple line-by-line summary of the Serverless compute plane networking (08/04/2025): General idea Serverless egress control (outbound connections) Network Connectivity Configuration (NCC) What NCC enables: Extra…

Read More

Databrick Serverless compute limitations

Here’s a simple, line-by-line summary of the Serverless compute limitations (09/29/2025): General limitations Streaming limitations Machine learning limitations Notebook limitations Job limitations Compute-specific limitations Caching limitations Hive…

Read More

Best practices for Databrick serverless compute

Best practices for serverless compute Big picture Before you migrate Ingesting data (getting data in) Querying external data (without moving it) Spark configurations Watch your costs Quick…

Read More

Databrick Serverless compute release

Here’s a simple line-by-line summary of the important points from the Serverless Compute release notes (09/24/2025): Perfect 👍 Here’s a one-page cheat sheet table for the Serverless…

Read More
guest
0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x