Loading...
Loading...
Compare original and translation side by side
query_system_catalogquery_system_catalogmz_ontologySHOW TABLES FROM mz_ontologymz_ontologySHOW TABLES FROM mz_ontology| Table | What it tells you |
|---|---|
| What catalog entities exist and which |
| Relationships between entities (foreign keys, metrics, etc.). |
| Column names, types, and descriptions for each entity. |
| Typed ID domains (CatalogItemId, ReplicaId, etc.). |
-- Find the right table for an entity
SELECT name, relation, description
FROM mz_ontology.mz_ontology_entity_types
WHERE name LIKE '%source%'
-- Find join paths between entities
SELECT name, source_entity, target_entity, properties, description
FROM mz_ontology.mz_ontology_link_types
WHERE source_entity = 'source' OR target_entity = 'source'
-- Find columns for a table
SELECT column_name, semantic_type, description
FROM mz_ontology.mz_ontology_properties
WHERE entity_type = 'source_status'| 表 | 作用 |
|---|---|
| 存在哪些目录实体,以及它们映射到哪个 |
| 实体间的关系(外键、指标等)。 |
| 每个实体的列名、类型及描述。 |
| 带类型的ID域(CatalogItemId、ReplicaId等)。 |
-- 查找实体对应的表
SELECT name, relation, description
FROM mz_ontology.mz_ontology_entity_types
WHERE name LIKE '%source%'
-- 查找实体间的关联路径
SELECT name, source_entity, target_entity, properties, description
FROM mz_ontology.mz_ontology_link_types
WHERE source_entity = 'source' OR target_entity = 'source'
-- 查找表的列
SELECT column_name, semantic_type, description
FROM mz_ontology.mz_ontology_properties
WHERE entity_type = 'source_status'SHOW COLUMNS FROM <schema>.<table>SHOW COLUMNS FROM <schema>.<table>| Wrong | Correct | Table |
|---|---|---|
| | |
| Must JOIN through | |
SHOW COLUMNS FROM <schema>.<table>| 错误写法 | 正确写法 | 表 |
|---|---|---|
| | |
| 必须通过 | |
SHOW COLUMNS FROM <schema>.<table>mz_introspection.mz_dataflow_arrangement_sizesSET cluster = ...iduint8textmz_catalog.mz_objects.idoperator does not exist: uint8 = textmz_internal.mz_cluster_replica_utilizationmz_internal.mz_cluster_replica_metricsmz_internal.mz_index_advicemz_introspection.mz_dataflow_arrangement_sizesSET cluster = ...iduint8mz_catalog.mz_objects.idtextoperator does not exist: uint8 = textmz_internal.mz_cluster_replica_utilizationmz_internal.mz_cluster_replica_metricsmz_internal.mz_index_advicemz_introspectionuint8textmz_introspectionmz_catalogmz_internaltextmz_catalogmz_introspectionuint8textmz_introspectionmz_catalogmz_internaltextmz_catalogmz_ontologySHOW COLUMNS FROM <schema>.<table>SHOW TABLES FROM mz_internal LIKE '...'mz_ontologySHOW COLUMNS FROM <schema>.<table>SHOW TABLES FROM mz_internal LIKE '...'query_system_catalogquery_system_catalog: SELECT mz_version().mcp.jsonenable_mcp_developerquery_system_catalogquery_system_catalog: SELECT mz_version().mcp.jsonenable_mcp_developerquery_system_catalogSETmz_catalogmz_internalpg_cataloginformation_schemamz_introspectionquery_system_catalogSETmz_catalogmz_internalpg_cataloginformation_schemamz_introspectionreferences/queries.mdreferences/queries.mdSELECT mz_version()SELECT mz_version()references/queries.mdreferences/queries.mdmz_internal.mz_materialization_lagwrite_frontiermz_timestampnow()to_timestamp(write_frontier::bigint / 1000)mz_internal.mz_materialization_lagwrite_frontiermz_timestampnow()to_timestamp(write_frontier::bigint / 1000)mz_internal.mz_hydration_statusesmz_internal.mz_hydration_statusesmz_internal.mz_cluster_replica_utilizationmz_internal.mz_cluster_replica_metricsmz_internal.mz_index_advicemz_internal.mz_cluster_replica_utilizationmz_internal.mz_cluster_replica_metricsmz_internal.mz_index_advicemz_internal.mz_index_advicemz_internal.mz_index_advicemz_catalog.mz_cluster_replica_sizescredits_per_hour * replication_factor * 730 hours/monthmz_catalog.mz_cluster_replica_sizescredits_per_hour * replication_factor * 730 hours/monthmz_internal.mz_object_dependenciesmz_internal.mz_object_dependenciesundefinedundefinedundefinedRecommendation: Dematerializeto save memory.my_schema.unused_mvsqlSHOW CREATE MATERIALIZED VIEW my_schema.unused_mv; DROP MATERIALIZED VIEW my_schema.unused_mv; CREATE VIEW my_schema.unused_mv AS <definition>;
Recommendation: Consider dematerializing.my_schema.unused_mv
推荐: 将转为非物化视图以节省内存。my_schema.unused_mvsqlSHOW CREATE MATERIALIZED VIEW my_schema.unused_mv; DROP MATERIALIZED VIEW my_schema.unused_mv; CREATE VIEW my_schema.unused_mv AS <定义>;
推荐: 考虑将转为非物化视图。my_schema.unused_mv
mz_internal.mz_materialization_lagmz_internal.mz_hydration_statusesmz_internal.mz_cluster_replica_statusesmz_internal.mz_cluster_replica_utilizationmz_internal.mz_source_statuses-- Option A: Scale up the cluster
ALTER CLUSTER <cluster_name> SET (SIZE = '<next_size_up>');
-- Option B: Move the MV to a different cluster
SHOW CREATE MATERIALIZED VIEW <schema>.<mv_name>;
DROP MATERIALIZED VIEW <schema>.<mv_name>;
CREATE MATERIALIZED VIEW <schema>.<mv_name> IN CLUSTER <new_cluster> AS <definition>;SELECT name, status, error, last_status_change_at
FROM mz_internal.mz_source_statuses
WHERE status != 'running'mz_internal.mz_materialization_lagmz_internal.mz_hydration_statusesmz_internal.mz_cluster_replica_statusesmz_internal.mz_cluster_replica_utilizationmz_internal.mz_source_statuses-- 方案A:升级集群规格
ALTER CLUSTER <cluster_name> SET (SIZE = '<更高规格>');
-- 方案B:将MV迁移至其他集群
SHOW CREATE MATERIALIZED VIEW <schema>.<mv_name>;
DROP MATERIALIZED VIEW <schema>.<mv_name>;
CREATE MATERIALIZED VIEW <schema>.<mv_name> IN CLUSTER <新集群> AS <定义>;SELECT name, status, error, last_status_change_at
FROM mz_internal.mz_source_statuses
WHERE status != 'running'mz_internal.mz_cluster_replica_utilizationmz_internal.mz_index_adviceSELECT o.name, o.type, sc.name AS schema_name, ia.hint, ia.details
FROM mz_internal.mz_index_advice ia
JOIN mz_catalog.mz_objects o ON ia.object_id = o.id
JOIN mz_catalog.mz_schemas sc ON o.schema_id = sc.id
WHERE ia.hint = 'convert to a view'
-- For each candidate:
SHOW CREATE MATERIALIZED VIEW <schema>.<mv_name>;
DROP MATERIALIZED VIEW <schema>.<mv_name>;
CREATE VIEW <schema>.<mv_name> AS <definition>;SELECT o.name, o.type, sc.name AS schema_name, ia.hint, ia.details
FROM mz_internal.mz_index_advice ia
JOIN mz_catalog.mz_objects o ON ia.object_id = o.id
JOIN mz_catalog.mz_schemas sc ON o.schema_id = sc.id
WHERE ia.hint = 'drop unless queried directly'
-- Verify with the user before dropping
DROP INDEX <schema>.<index_name>;ALTER CLUSTER <cluster_name> SET (SIZE = '<next_size_up>');mz_internal.mz_cluster_replica_utilizationmz_internal.mz_index_adviceSELECT o.name, o.type, sc.name AS schema_name, ia.hint, ia.details
FROM mz_internal.mz_index_advice ia
JOIN mz_catalog.mz_objects o ON ia.object_id = o.id
JOIN mz_catalog.mz_schemas sc ON o.schema_id = sc.id
WHERE ia.hint = 'convert to a view'
-- 对每个候选对象执行:
SHOW CREATE MATERIALIZED VIEW <schema>.<mv_name>;
DROP MATERIALIZED VIEW <schema>.<mv_name>;
CREATE VIEW <schema>.<mv_name> AS <定义>;SELECT o.name, o.type, sc.name AS schema_name, ia.hint, ia.details
FROM mz_internal.mz_index_advice ia
JOIN mz_catalog.mz_objects o ON ia.object_id = o.id
JOIN mz_catalog.mz_schemas sc ON o.schema_id = sc.id
WHERE ia.hint = 'drop unless queried directly'
-- 先与用户确认再删除
DROP INDEX <schema>.<index_name>;ALTER CLUSTER <cluster_name> SET (SIZE = '<更高规格>');mz_internal.mz_source_statusesmz_internal.mz_source_statisticsmz_internal.mz_materialization_lagSELECT name, status, error
FROM mz_internal.mz_source_statuses
WHERE status != 'running'
-- If the connection credentials are wrong:
ALTER SECRET <secret_name> AS '<new_value>';snapshot_committedfalsemz_internal.mz_source_statusesmz_internal.mz_source_statisticsmz_internal.mz_materialization_lagSELECT name, status, error
FROM mz_internal.mz_source_statuses
WHERE status != 'running'
-- 若连接凭证错误:
ALTER SECRET <secret_name> AS '<新值>';snapshot_committedfalsemz_internal.mz_cluster_replica_statusesmz_internal.mz_source_statusesmz_internal.mz_sink_statusesmz_internal.mz_cluster_replica_utilizationmz_internal.mz_cluster_replica_statusesmz_internal.mz_source_statusesmz_internal.mz_sink_statusesmz_internal.mz_cluster_replica_utilizationmz_internal.mz_index_advicemz_catalog.mz_cluster_replica_sizesmz_internal.mz_index_advicemz_catalog.mz_cluster_replica_sizes