找出连续聚合的大小
Finding out the size of a continuous aggregate
拥有 hypertable table 和几百万行。我可以 select 使用以下方法来调整大小:
SELECT pg_size_pretty( pg_total_relation_size('towns') );
我也有那个 hypertable 的连续聚合:
WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS
SELECT time_bucket(INTERVAL '1 minute', timestamp) AS bucket,
/* random query */
FROM towns
GROUP BY bucket, town
WITH NO DATA;
我刷新了视图,数据按预期显示。但是,我似乎无法弄清楚 space 这个新视图占用了多少。
SELECT pg_size_pretty( pg_total_relation_size('towns_income') );
returns 0 个字节,我知道这是不正确的。我认为 towns
的 total_relation_size 可能会增加,但这似乎也是一样的。我错过了什么吗?我也试过 hypertable_size
但没有成功,因为 mv 在技术上不是 hypertable。
以下SQL可以提供帮助:)
SELECT view_name, hypertable_size(format('%I.%I', materialization_hypertable_schema , materialization_hypertable_name )::regclass)
FROM timescaledb_information.continuous_aggregates;
另一种方法是以下 SQL 查询
SELECT pg_size_pretty(SUM(total_bytes)), aggs.view_name
FROM "_timescaledb_internal".hypertable_chunk_local_size hcls, timescaledb_information.continuous_aggregates aggs
WHERE hcls.table_name = aggs.materialization_hypertable_name
GROUP BY aggs.view_name;
拥有 hypertable table 和几百万行。我可以 select 使用以下方法来调整大小:
SELECT pg_size_pretty( pg_total_relation_size('towns') );
我也有那个 hypertable 的连续聚合:
WITH (timescaledb.continuous, timescaledb.materialized_only=true) AS
SELECT time_bucket(INTERVAL '1 minute', timestamp) AS bucket,
/* random query */
FROM towns
GROUP BY bucket, town
WITH NO DATA;
我刷新了视图,数据按预期显示。但是,我似乎无法弄清楚 space 这个新视图占用了多少。
SELECT pg_size_pretty( pg_total_relation_size('towns_income') );
returns 0 个字节,我知道这是不正确的。我认为 towns
的 total_relation_size 可能会增加,但这似乎也是一样的。我错过了什么吗?我也试过 hypertable_size
但没有成功,因为 mv 在技术上不是 hypertable。
以下SQL可以提供帮助:)
SELECT view_name, hypertable_size(format('%I.%I', materialization_hypertable_schema , materialization_hypertable_name )::regclass)
FROM timescaledb_information.continuous_aggregates;
另一种方法是以下 SQL 查询
SELECT pg_size_pretty(SUM(total_bytes)), aggs.view_name
FROM "_timescaledb_internal".hypertable_chunk_local_size hcls, timescaledb_information.continuous_aggregates aggs
WHERE hcls.table_name = aggs.materialization_hypertable_name
GROUP BY aggs.view_name;