Introduction
Materialize enables you to transform, deliver, and act on fast-changing data using standard SQL. Unlike traditional databases, Materialize maintains query results incrementally — as new data arrives, it updates only what changed, providing consistently fresh results with minimal latency. This is fundamentally different from batch processing or periodic refresh patterns. Materialize recasts your SQL queries as dataflows that react efficiently to changes in real-time.How Materialize transforms data
SELECT statements
At the core of data transformation in Materialize is theSELECT statement. You can query from:
- Sources - streaming data from Kafka, PostgreSQL CDC, MySQL CDC, or webhooks
- Tables - user-defined data stored in Materialize
- Views - saved query definitions
- Materialized views - persisted, incrementally-maintained query results
Key SQL capabilities
Materialize supports comprehensive SQL functionality:- Joins - inner, left outer, right outer, full outer, cross joins, and lateral subqueries
- Aggregations -
SUM,COUNT,AVG,MIN,MAX,STDDEV, and more - Window operations - through idiomatic patterns optimized for streaming
- Common Table Expressions (CTEs) - including recursive CTEs
- Subqueries - with automatic decorrelation optimization
- Complex filtering - including temporal filters with
mz_now()
Views vs materialized views
Regular views
A view is a named SQL query that doesn’t compute results until queried:Materialized views
A materialized view persists results in durable storage and incrementally updates them as data changes:- Cross-cluster access - query results from any cluster, not just where they’re maintained
- Durability - results survive cluster restarts
- External sinks - push results to Kafka or other systems
- Separation of compute - maintain views on one cluster, query from another
Incremental maintenance
The power of Materialize lies in incremental view maintenance. Instead of recomputing entire query results on every data change, Materialize:- Tracks changes - monitors inserts, updates, and deletes in source data
- Propagates updates - flows changes through the query dataflow
- Updates incrementally - modifies only affected result rows
- Maintains consistency - ensures all views reflect a consistent snapshot of input data
Example: TPC-H Query 15
Here’s a real-world example showing Materialize’s capabilities with a complex TPC-H benchmark query:tpch_q15 incrementally. You can query it immediately:
PostgreSQL compatibility
Materialize supports a large subset of PostgreSQL syntax and semantics, making it easy to:- Use familiar SQL patterns from PostgreSQL
- Connect with PostgreSQL-compatible tools and clients (pgAdmin, DBeaver, etc.)
- Migrate queries with minimal changes
- Use the
psqlclient or any PostgreSQL driver
Query optimization
Materialize automatically optimizes queries through:- Subquery decorrelation - rewrites correlated subqueries for efficiency
- Join ordering - selects optimal join execution plans
- Delta joins - avoids intermediate state blowup in multi-way joins
- Index selection - uses indexes for point lookups and range scans
- Filter pushdown - applies filters as early as possible
Next steps
SQL Views
Learn about regular views, indexes, and when to use each
Materialized Views
Deep dive into durable, cross-cluster materialized views
Joins
Master multi-way joins, outer joins, and self-joins
Aggregations
Explore GROUP BY, HAVING, and window functions