In a 'vanilla' PostgreSQL 12.7 database, I generally run the following query to learn the estimated number of rows in tables with 100+ million rows:

-- Return the estimated number of rows for the given table
SELECT reltuples::bigint AS estimate_number_of_rows
FROM   pg_class
WHERE  oid = to_regclass('name_of_some_big_table');

This type of query doesn't work for a distributed hypertable on our multi-node TimescaleDB installation.

I checked the TimescaleDB API Reference but couldn't find what I'm looking for.

Is there such a straightforward query to quickly return the estimated number of rows in a distributed hypertable?

1 Answer 1


TimescaleDB provides approximate_row_count function, which is described in the documentation here. The accuracy depends when ANALYZE or VACUUM was run last time.

For your table the query will be:

SELECT approximate_row_count('name_of_some_big_table');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.