Skip to main content

Overview

The mz_catalog schema exposes metadata about your Materialize instance in its native format. This is the recommended interface for querying system metadata, as it provides the most accurate and complete representation of Materialize objects. All tables and views in mz_catalog are automatically available in every database without any special configuration.
Views that reference mz_catalog tables cannot use SELECT * or NATURAL JOIN. You must explicitly list all columns and use USING joins instead.

Core Object Tables

mz_databases

Contains one row for each database in the system.
ColumnTypeDescription
idtextMaterialize’s unique ID for the database
oidoidPostgreSQL-compatible OID
nametextThe name of the database
owner_idtextThe role ID of the owner
privilegesmz_aclitem[]Access control privileges
Example:
-- List all databases and their owners
SELECT 
  d.name AS database_name,
  r.name AS owner_name
FROM mz_catalog.mz_databases d
JOIN mz_catalog.mz_roles r ON d.owner_id = r.id;

mz_schemas

Contains one row for each schema in the system.
ColumnTypeDescription
idtextMaterialize’s unique ID for the schema
oidoidPostgreSQL-compatible OID
database_idtextThe ID of the containing database
nametextThe name of the schema
owner_idtextThe role ID of the owner
privilegesmz_aclitem[]Access control privileges
Example:
-- List all schemas in the current database
SELECT 
  s.name AS schema_name,
  d.name AS database_name
FROM mz_catalog.mz_schemas s
JOIN mz_catalog.mz_databases d ON s.database_id = d.id;

mz_objects

Unified view containing one row for each table, source, view, materialized view, sink, index, connection, secret, type, and function in the system.
ColumnTypeDescription
idtextMaterialize’s unique ID
oidoidPostgreSQL-compatible OID
schema_idtextThe ID of the containing schema
nametextThe name of the object
typetextObject type: table, source, view, materialized-view, sink, index, connection, secret, type, or function
owner_idtextThe role ID of the owner
cluster_idtextThe cluster ID (for sources, MVs, indexes, sinks)
privilegesmz_aclitem[]Access control privileges
Example:
-- List all objects in the public schema
SELECT name, type 
FROM mz_catalog.mz_objects
WHERE schema_id = (SELECT id FROM mz_catalog.mz_schemas WHERE name = 'public')
ORDER BY type, name;

Sources

mz_sources

Contains one row for each source in the system.
ColumnTypeDescription
idtextUnique ID for the source
oidoidPostgreSQL-compatible OID
schema_idtextThe ID of the containing schema
nametextThe name of the source
typetextSource type: kafka, mysql, postgres, load-generator, progress, or subsource
connection_idtextThe ID of the associated connection
sizetextThe size of the source (deprecated)
envelope_typetextFor Kafka sources: none, upsert, or debezium
key_formattextFor Kafka sources: message key format
value_formattextFor Kafka sources: message value format
cluster_idtextThe cluster maintaining the source
owner_idtextThe role ID of the owner
privilegesmz_aclitem[]Access control privileges
create_sqltextThe CREATE statement
redacted_create_sqltextCREATE statement with secrets redacted
Example:
-- List all Kafka sources with their topics
SELECT 
  s.name AS source_name,
  s.type,
  ks.topic,
  c.name AS cluster_name
FROM mz_catalog.mz_sources s
JOIN mz_catalog.mz_kafka_sources ks ON s.id = ks.id
JOIN mz_catalog.mz_clusters c ON s.cluster_id = c.id
WHERE s.type = 'kafka';

mz_kafka_sources

Contains details specific to Kafka sources.
ColumnTypeDescription
idtextThe ID of the Kafka source
group_id_prefixtextThe consumer group ID prefix
topictextThe Kafka topic name
Example:
-- Monitor Kafka source lag
SELECT
  s.name,
  ks.topic,
  st.offset_known - st.offset_committed AS lag
FROM mz_catalog.mz_sources s
JOIN mz_catalog.mz_kafka_sources ks ON s.id = ks.id
JOIN mz_internal.mz_source_statistics st ON s.id = st.id
WHERE st.snapshot_committed;

Views and Materialized Views

mz_views

Contains one row for each view in the system.
ColumnTypeDescription
idtextUnique ID for the view
oidoidPostgreSQL-compatible OID
schema_idtextThe ID of the containing schema
nametextThe name of the view
definitiontextThe view’s SELECT query
owner_idtextThe role ID of the owner
privilegesmz_aclitem[]Access control privileges
create_sqltextThe CREATE statement
redacted_create_sqltextCREATE statement with secrets redacted
Example:
-- Find views that query a specific source
SELECT v.name, v.definition
FROM mz_catalog.mz_views v
WHERE v.definition LIKE '%my_source%';

mz_materialized_views

Contains one row for each materialized view in the system.
ColumnTypeDescription
idtextUnique ID for the materialized view
oidoidPostgreSQL-compatible OID
schema_idtextThe ID of the containing schema
nametextThe name of the materialized view
cluster_idtextThe cluster maintaining the MV
definitiontextThe MV’s SELECT query
owner_idtextThe role ID of the owner
privilegesmz_aclitem[]Access control privileges
create_sqltextThe CREATE statement
redacted_create_sqltextCREATE statement with secrets redacted
Example:
-- List materialized views with their storage usage
SELECT 
  mv.name,
  c.name AS cluster_name,
  u.size_bytes / (1024 * 1024) AS size_mb
FROM mz_catalog.mz_materialized_views mv
JOIN mz_catalog.mz_clusters c ON mv.cluster_id = c.id
JOIN mz_catalog.mz_recent_storage_usage u ON mv.id = u.object_id
ORDER BY u.size_bytes DESC;

Indexes

mz_indexes

Contains one row for each index in the system.
ColumnTypeDescription
idtextUnique ID for the index
oidoidPostgreSQL-compatible OID
nametextThe name of the index
on_idtextThe ID of the relation being indexed
cluster_idtextThe cluster maintaining the index
owner_idtextThe role ID of the owner
create_sqltextThe CREATE INDEX statement
redacted_create_sqltextCREATE statement with secrets redacted
Example:
-- List all indexes and what they index
SELECT 
  i.name AS index_name,
  o.name AS indexed_object,
  o.type AS object_type,
  c.name AS cluster_name
FROM mz_catalog.mz_indexes i
JOIN mz_catalog.mz_objects o ON i.on_id = o.id
JOIN mz_catalog.mz_clusters c ON i.cluster_id = c.id;

mz_index_columns

Contains one row for each column in each index.
ColumnTypeDescription
index_idtextThe ID of the index
index_positionuint8Position within the index (1-based)
on_positionuint8Position in the indexed relation (1-based)
on_expressiontextSQL expression for computed columns
nullablebooleanWhether the column can be NULL
Example:
-- Show index structure
SELECT 
  i.name AS index_name,
  ic.index_position,
  COALESCE(
    c.name,
    ic.on_expression
  ) AS column_def
FROM mz_catalog.mz_indexes i
JOIN mz_catalog.mz_index_columns ic ON i.id = ic.index_id
LEFT JOIN mz_catalog.mz_columns c 
  ON i.on_id = c.id 
  AND ic.on_position = c.position
WHERE i.name = 'my_index'
ORDER BY ic.index_position;

Clusters

mz_clusters

Contains one row for each cluster in the system.
ColumnTypeDescription
idtextUnique ID for the cluster
nametextThe name of the cluster
owner_idtextThe role ID of the owner
privilegesmz_aclitem[]Access control privileges
managedbooleanWhether the cluster is managed
sizetextFor managed clusters: replica size
replication_factoruint4For managed clusters: number of replicas
diskbooleanWhether replicas have local disk
availability_zonestext[]List of availability zones
introspection_debuggingbooleanWhether introspection debugging is enabled
introspection_intervalintervalIntrospection collection interval
Example:
-- List all clusters with their configuration
SELECT 
  name,
  managed,
  size,
  replication_factor
FROM mz_catalog.mz_clusters
ORDER BY name;

mz_cluster_replicas

Contains one row for each cluster replica.
ColumnTypeDescription
idtextUnique ID for the replica
nametextThe name of the replica
cluster_idtextThe ID of the parent cluster
sizetextThe replica’s size
availability_zonetextThe AZ where the replica runs
owner_idtextThe role ID of the owner
diskbooleanWhether the replica has local disk
Example:
-- Show cluster topology
SELECT 
  c.name AS cluster,
  r.name AS replica,
  r.size,
  r.availability_zone
FROM mz_catalog.mz_clusters c
JOIN mz_catalog.mz_cluster_replicas r ON c.id = r.cluster_id
ORDER BY c.name, r.name;

mz_cluster_replica_sizes

Contains the mapping between logical sizes (e.g., 100cc) and physical resources.
ColumnTypeDescription
sizetextThe human-readable size
processesuint8Number of processes
workersuint8Number of workers per process
cpu_nano_coresuint8CPU allocation per process
memory_bytesuint8RAM allocation per process
disk_bytesuint8Disk allocation per process
credits_per_hournumericCompute credits consumed per hour
The values in this table may change at any time. Do not rely on them for capacity planning.
Example:
-- Calculate cluster costs
SELECT 
  c.name AS cluster,
  c.replication_factor,
  s.size,
  s.credits_per_hour,
  s.credits_per_hour * c.replication_factor AS total_credits_per_hour
FROM mz_catalog.mz_clusters c
JOIN mz_catalog.mz_cluster_replica_sizes s ON c.size = s.size
WHERE c.managed;

Sinks

mz_sinks

Contains one row for each sink in the system.
ColumnTypeDescription
idtextUnique ID for the sink
oidoidPostgreSQL-compatible OID
schema_idtextThe ID of the containing schema
nametextThe name of the sink
typetextThe sink type: kafka
connection_idtextThe ID of the connection
sizetextThe sink’s size
envelope_typetextEnvelope: upsert or debezium
formattextMessage format (deprecated)
key_formattextKey format: avro, json, bytes, text
value_formattextValue format: avro, json, text, bytes
cluster_idtextThe cluster maintaining the sink
owner_idtextThe role ID of the owner
create_sqltextThe CREATE SINK statement
redacted_create_sqltextCREATE statement with secrets redacted
Example:
-- List all sinks and their destinations
SELECT 
  s.name AS sink_name,
  ks.topic AS kafka_topic,
  c.name AS cluster_name
FROM mz_catalog.mz_sinks s
JOIN mz_catalog.mz_kafka_sinks ks ON s.id = ks.id
JOIN mz_catalog.mz_clusters c ON s.cluster_id = c.id;

Tables and Columns

mz_tables

Contains one row for each table in the system.
ColumnTypeDescription
idtextUnique ID for the table
oidoidPostgreSQL-compatible OID
schema_idtextThe ID of the containing schema
nametextThe name of the table
owner_idtextThe role ID of the owner
privilegesmz_aclitem[]Access control privileges
create_sqltextThe CREATE TABLE statement
redacted_create_sqltextCREATE statement with secrets redacted
source_idtextAssociated source ID, if any

mz_columns

Contains one row for each column in each table, source, and view.
ColumnTypeDescription
idtextThe ID of the containing relation
nametextThe name of the column
positionuint8Position in the relation (1-based)
nullablebooleanWhether the column can be NULL
typetextThe data type of the column
defaulttextDefault value expression
type_oidoidThe OID of the column’s type
type_modintegerType modifier
Example:
-- Show table schema
SELECT 
  c.name AS column_name,
  c.type AS data_type,
  c.nullable,
  c.default
FROM mz_catalog.mz_columns c
JOIN mz_catalog.mz_tables t ON c.id = t.id
WHERE t.name = 'my_table'
ORDER BY c.position;

Connections and Secrets

mz_connections

Contains one row for each connection in the system.
ColumnTypeDescription
idtextUnique ID for the connection
oidoidPostgreSQL-compatible OID
schema_idtextThe ID of the containing schema
nametextThe name of the connection
typetextConnection type: confluent-schema-registry, kafka, postgres, or ssh-tunnel
owner_idtextThe role ID of the owner
privilegesmz_aclitem[]Access control privileges
create_sqltextThe CREATE CONNECTION statement
redacted_create_sqltextCREATE statement with secrets redacted

mz_secrets

Contains one row for each secret in the system.
ColumnTypeDescription
idtextUnique ID for the secret
oidoidPostgreSQL-compatible OID
schema_idtextThe ID of the containing schema
nametextThe name of the secret
owner_idtextThe role ID of the owner
privilegesmz_aclitem[]Access control privileges

Roles and Security

mz_roles

Contains one row for each role in the system.
ColumnTypeDescription
idtextUnique ID for the role
oidoidPostgreSQL-compatible OID
nametextThe name of the role
inheritbooleanWhether the role inherits privileges
rolcanloginbooleanWhether the role can log in
rolsuperbooleanWhether the role is a superuser
Example:
-- List all users who can log in
SELECT name, rolsuper
FROM mz_catalog.mz_roles
WHERE rolcanlogin = true
ORDER BY name;

mz_role_members

Contains role membership information.
ColumnTypeDescription
role_idtextThe ID of the parent role
membertextThe ID of the member role
grantortextThe ID of the role that granted membership
Example:
-- Show role hierarchy
SELECT 
  parent.name AS role,
  member.name AS member,
  grantor.name AS granted_by
FROM mz_catalog.mz_role_members rm
JOIN mz_catalog.mz_roles parent ON rm.role_id = parent.id
JOIN mz_catalog.mz_roles member ON rm.member = member.id
JOIN mz_catalog.mz_roles grantor ON rm.grantor = grantor.id;

Auditing

mz_audit_events

Records create, alter, and drop events for system objects.
ColumnTypeDescription
iduint8Unique, monotonically increasing event ID
event_typetextEvent type: create, drop, or alter
object_typetextObject type affected
detailsjsonbAdditional event details
usertextUser who triggered the event (or NULL if system)
occurred_attimestamp with time zoneWhen the event occurred
Example:
-- Show recent DDL changes
SELECT 
  occurred_at,
  event_type,
  object_type,
  user,
  details->>'name' AS object_name
FROM mz_catalog.mz_audit_events
WHERE object_type IN ('source', 'view', 'materialized-view')
ORDER BY occurred_at DESC
LIMIT 50;

Storage and Resource Monitoring

mz_recent_storage_usage

Contains the most recent storage usage assessment for each table, source, and materialized view.
ColumnTypeDescription
object_idtextThe ID of the object
size_bytesuint8Storage bytes used
Example:
-- Top 10 objects by storage usage
SELECT 
  o.name,
  o.type,
  u.size_bytes / (1024 * 1024 * 1024.0) AS size_gb
FROM mz_catalog.mz_recent_storage_usage u
JOIN mz_catalog.mz_objects o ON u.object_id = o.id
ORDER BY u.size_bytes DESC
LIMIT 10;

mz_storage_usage

This view is not indexed and can be slow to query. Use mz_recent_storage_usage when possible.
Contains historical storage usage data with periodic assessments.
ColumnTypeDescription
object_idtextThe ID of the object
size_bytesuint8Storage bytes used
collection_timestamptimestamp with time zoneWhen usage was assessed
Example:
-- Track storage growth over time for a specific object
SELECT 
  collection_timestamp,
  size_bytes / (1024 * 1024 * 1024.0) AS size_gb
FROM mz_catalog.mz_storage_usage
WHERE object_id = (SELECT id FROM mz_catalog.mz_materialized_views WHERE name = 'my_mv')
ORDER BY collection_timestamp DESC
LIMIT 24; -- Last 24 hours

mz_cluster_replica_frontiers

Describes the per-replica frontiers of sources, sinks, materialized views, indexes, and subscriptions.
ColumnTypeDescription
object_idtextThe ID of the object
replica_idtextThe ID of the replica
write_frontiermz_timestampThe next timestamp at which output may change
Example:
-- Check frontier alignment across replicas
SELECT 
  o.name AS object,
  r.name AS replica,
  f.write_frontier
FROM mz_catalog.mz_cluster_replica_frontiers f
JOIN mz_catalog.mz_objects o ON f.object_id = o.id
JOIN mz_catalog.mz_cluster_replicas r ON f.replica_id = r.id
WHERE o.name = 'my_materialized_view';

Types and Functions

mz_types

Contains one row for each type in the system.
ColumnTypeDescription
idtextUnique ID for the type
oidoidPostgreSQL-compatible OID
schema_idtextThe ID of the containing schema
nametextThe name of the type
categorytextThe category of the type
owner_idtextThe role ID of the owner
privilegesmz_aclitem[]Access control privileges
create_sqltextThe CREATE TYPE statement
redacted_create_sqltextCREATE statement with secrets redacted

mz_functions

Contains one row for each function in the system.
ColumnTypeDescription
idtextUnique ID for the function
oidoidPostgreSQL-compatible OID
schema_idtextThe ID of the containing schema
nametextThe name of the function
argument_type_idstext[]IDs of argument types
variadic_argument_type_idtextID of variadic argument type
return_type_idtextID of return type
returns_setbooleanWhether the function returns a set
owner_idtextThe role ID of the owner

Advanced Monitoring Queries

Monitor Source Snapshotting Progress

SELECT
  o.name,
  s.snapshot_records_staged,
  s.snapshot_records_known,
  ROUND(
    100.0 * s.snapshot_records_staged / 
    NULLIF(s.snapshot_records_known, 0), 
    2
  ) AS snapshot_completed_pct
FROM mz_internal.mz_source_statistics s
JOIN mz_catalog.mz_objects o ON s.id = o.id
WHERE NOT s.snapshot_committed;

Find Unused Indexes

-- Indexes that might not be needed
SELECT 
  i.name AS index_name,
  o.name AS indexed_object
FROM mz_catalog.mz_indexes i
JOIN mz_catalog.mz_objects o ON i.on_id = o.id
WHERE NOT EXISTS (
  SELECT 1 
  FROM mz_internal.mz_compute_dependencies d
  WHERE d.dependency_id = i.id
);

Cluster Resource Allocation Summary

SELECT 
  c.name AS cluster,
  COUNT(DISTINCT r.id) AS replica_count,
  s.size,
  s.cpu_nano_cores / 1000000000.0 AS cpu_cores,
  s.memory_bytes / (1024.0 * 1024 * 1024) AS memory_gb,
  s.credits_per_hour * COUNT(DISTINCT r.id) AS total_credits_per_hour
FROM mz_catalog.mz_clusters c
JOIN mz_catalog.mz_cluster_replicas r ON c.id = r.cluster_id
JOIN mz_catalog.mz_cluster_replica_sizes s ON r.size = s.size
GROUP BY c.name, s.size, s.cpu_nano_cores, s.memory_bytes, s.credits_per_hour
ORDER BY total_credits_per_hour DESC;

See Also

Build docs developers (and LLMs) love