Select estimated rows count from timescaledb
SELECT h.schema_name, h.table_name, h.id AS table_id, h.associated_table_prefix, row_estimate.row_estimate FROM _timescaledb_catalog.hypertable h CROSS JOIN LATERAL ( SELECT sum(cl.reltuples) AS row_estimate FROM _timescaledb_catalog.chunk c JOIN pg_class cl ON cl.relname = c.table_name WHERE c.hypertable_id = h.id GROUP BY h.schema_name, h.table_name) row_estimate ORDER BY schema_name, table_name;
6 мая 2021, 13:31