To determine the size of my TimescaleDB table my_table
(which has a hypertable created previously), I ran the SQL query
pg_size_pretty( pg_total_relation_size('my_table') );
However, despite having 10k rows in this table, the size returned from this query is 24 kB.
Querying for the size of the database gave a more reasonable size of 34 MB, using the SQL query
SELECT pg_size_pretty( pg_database_size('database_development') );
Question: What is the correct way for calculating the size of a TimescaleDB table?
Using PostgreSQL 11.5, TimescaleDB 1.5.1
When you insert data from a time range that doesn't yet have a chunk, TimescaleDB automatically creates a chunk to store it. By default, each chunk covers 7 days. You can change this to better suit your needs. For example, if you set chunk_time_interval to 1 day, each chunk stores data from the same day.
We typically recommend using TimescaleDB-specific functions:
https://docs.timescale.com/latest/api#hypertable_relation_size https://docs.timescale.com/latest/api#hypertable_relation_size_pretty
If you are interested in getting information about each/specific chunk:
https://docs.timescale.com/latest/api#chunk_relation_size https://docs.timescale.com/latest/api#chunk_relation_size_pretty
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With