我已经在timescale db中创建了一个hypertable并持久化了数据,我想查看其中的块的时间范围。我该怎么做呢?有像chunk_relation_size_pretty这样的函数可以显示大小而不是时间范围。
chunk_relation_size_pretty
xoshrz7s1#
我使用这个视图来获取关于超表中块的信息。在https://github.com/timescale/timescaledb-extras下也有两个版本,所以你也可以在那里检查。
CREATE SCHEMA info; CREATE OR REPLACE VIEW info.chunks AS SELECT format('%1$I.%2$I', ch.schema_name, ch.table_name)::regclass AS chunk , format('%1$I.%2$I', ht.schema_name, ht.table_name)::regclass AS hypertable , tstzrange(TIMESTAMPTZ 'epoch' + sl.range_start * INTERVAL '1 microsecond', TIMESTAMPTZ 'epoch' + sl.range_end * INTERVAL '1 microsecond') AS date_range , (SELECT (SELECT spcname FROM pg_tablespace WHERE reltablespace = oid) FROM pg_class WHERE format('%1$I.%2$I', ch.schema_name, ch.table_name)::regclass = pg_class.oid) AS tablespace FROM _timescaledb_catalog.chunk ch JOIN _timescaledb_catalog.hypertable ht ON ch.hypertable_id = ht.id JOIN _timescaledb_catalog.dimension di ON di.hypertable_id = ht.id JOIN _timescaledb_catalog.chunk_constraint cn ON cn.chunk_id = ch.id JOIN _timescaledb_catalog.dimension_slice sl ON cn.dimension_slice_id = sl.id WHERE column_type = 'timestamptz'::regtype;
字符串
eeq64g8w2#
我想这就是你要找的:SELECT * FROM timescaledb_information.chunks;
2条答案
按热度按时间xoshrz7s1#
我使用这个视图来获取关于超表中块的信息。在https://github.com/timescale/timescaledb-extras下也有两个版本,所以你也可以在那里检查。
字符串
eeq64g8w2#
我想这就是你要找的:
SELECT * FROM timescaledb_information.chunks;