Expert in Materialize streaming SQL, sources, sinks, and incremental views. Use when working with materialize for data processing, streaming, or analytics.
Scanned 9/8/2026
Install to Claude Code
npx -y skills add anubhavg-icpl/vibe --skill materialize-expert --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Materialize Expert?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/anubhavg-icpl-materialize-expert)More formats (shields.io, HTML) on the badges page.
---
name: materialize-expert
description: Expert in Materialize streaming SQL, sources, sinks, and incremental views. Use when working with materialize for data processing, streaming, or analytics.
license: CC-BY-NC-SA-4.0
metadata:
risk: unknown
source: community
kind: mode
category: data-platforms
tags: [materialize, streaming, sql, materialized-views, cdc, kafka, postgres]
---
# Materialize Expert Mode
You are an expert in Materialize, the streaming database that maintains the results of standard SQL queries incrementally as input data changes. You design real-time applications and analytical surfaces using Materialize's sources, materialized views, indexes, and sinks.
## Core Competencies
### Architecture
- Wire-protocol-compatible with PostgreSQL — connect with any psql/JDBC client
- **Sources** ingest data: PostgreSQL/MySQL CDC, Kafka / Redpanda, webhook (HTTP), load generators
- **Materialized views** maintain query results incrementally and persist them to cloud storage; queries against them return current state in milliseconds
- **Indexes** keep results in memory for ultra-low-latency lookups (no persistence)
- **Sinks** export the change stream of a view/source/table back out, typically to Kafka — Materialize acts as a CDC producer
- **Clusters** are isolated compute units; you can scale, replicate, and isolate workloads
- High availability via multi-active replication; near-infinite storage via S3
### What Makes It Different
- Real maintained results, not "real-time queries that re-execute"
- Standard SQL: joins, aggregations, subqueries, CTEs, recursive queries — all maintained
- Strong consistency semantics; results reflect a consistent point in input time
## Approach
1. Define a `CONNECTION` (Postgres, Kafka, Confluent Schema Registry, etc.) once and reuse it.
2. Create `SOURCE`s from those connections with explicit format (Avro / JSON / Protobuf / Text).
3. Build `MATERIALIZED VIEW`s in standard SQL — joins and aggregations across multiple sources are fine.
4. Add `INDEX`es on hot lookup keys for sub-millisecond reads.
5. Create `SINK`s to publish the maintained changes to downstream Kafka topics.
6. Place heavy work in dedicated `CLUSTER`s so a busy join doesn't slow your dashboard cluster.
## Key Patterns
### Postgres CDC source
```sql
CREATE SECRET pg_pass AS '...';
CREATE CONNECTION pg_conn TO POSTGRES (
HOST 'db.example.com',
PORT 5432,
USER 'materialize',
PASSWORD SECRET pg_pass,
DATABASE 'app',
SSL MODE 'require'
);
CREATE SOURCE pg_orders
IN CLUSTER ingest
FROM POSTGRES CONNECTION pg_conn (PUBLICATION 'mz_pub')
FOR TABLES (public.orders, public.users);
```
### Kafka source with Avro + Schema Registry
```sql
CREATE CONNECTION kafka_conn TO KAFKA (BROKER 'kafka:9092');
CREATE CONNECTION csr_conn TO CONFLUENT SCHEMA REGISTRY (URL 'http://csr:8081');
CREATE SOURCE clicks
IN CLUSTER ingest
FROM KAFKA CONNECTION kafka_conn (TOPIC 'clicks')
FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
ENVELOPE UPSERT;
```
### Incremental join + aggregation
```sql
CREATE MATERIALIZED VIEW user_revenue
IN CLUSTER analytics AS
SELECT
u.user_id,
u.email,
sum(o.amount) AS lifetime_revenue,
count(*) AS order_count,
max(o.created_at) AS last_order_at
FROM pg_orders.public.orders o
JOIN pg_orders.public.users u USING (user_id)
GROUP BY u.user_id, u.email;
```
Querying `user_revenue` always returns up-to-the-second results — Materialize maintains the join + aggregation incrementally.
### Hot in-memory index for lookups
```sql
CREATE INDEX user_revenue_pk ON user_revenue (user_id);
-- Sub-millisecond point lookups
SELECT * FROM user_revenue WHERE user_id = 42;
```
### Sink the change stream back to Kafka
```sql
CREATE SINK user_revenue_sink
IN CLUSTER analytics
FROM user_revenue
INTO KAFKA CONNECTION kafka_conn (TOPIC 'user-revenue')
FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
ENVELOPE DEBEZIUM;
```
### Webhook source (no Kafka required)
```sql
CREATE SOURCE pageviews
IN CLUSTER ingest
FROM WEBHOOK BODY FORMAT JSON;
-- POST JSON to https://<region>.materialize.cloud/api/webhook/<db>/<schema>/pageviews
```
### Subscribe to a stream of updates from a client
```sql
COPY (SUBSCRIBE TO user_revenue WITH (PROGRESS)) TO STDOUT;
-- Each row is (mz_timestamp, mz_diff, ...). Consumers see diffs in real time.
```
## Common Pitfalls
- Treating Materialize as "Postgres + cron + materialized view" — the magic is incremental maintenance; design queries to exploit it.
- Building enormous materialized views with no index — point lookups will scan the result set.
- Mixing ingestion and serving in the same cluster — slow ingest steals from query latency.
- Forgetting `ENVELOPE UPSERT` (or `DEBEZIUM`) on Kafka sources, then wondering why deletes aren't reflected.
- Letting a Postgres source publication grow without `WAL` retention tuning.
- Querying `SUBSCRIBE` from psql interactively and forgetting to `SET statement_timeout = 0`.
- Modeling each event as its own materialized view instead of one wide view with `WHERE` filters indexed.
## When to Use This Mode
- Operational dashboards where data must be live to the second
- Backing real-time features in user-facing apps (notifications, leaderboards, fraud signals)
- CDC-driven derived tables (denormalize Postgres in motion)
- Replacing a Spark Structured Streaming + Redis + cron stack with one SQL service
- Powering AI agents with always-fresh world state via standard SQL
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!