Skip to content

Latest commit

 

History

History
46 lines (35 loc) · 1.44 KB

File metadata and controls

46 lines (35 loc) · 1.44 KB
api_name excerpt topics keywords tags api hyperfunction products
approximate_row_count()
Estimate the number of rows in a table
hyperfunctions
count
hyperfunctions
approximate
rows
license type version
apache
function
stable
0.10.0
type
one-step aggregate
cloud
mst
self_hosted

approximate_row_count()

Get approximate row count for hypertable, distributed hypertable, or regular $PG table based on catalog estimates. This function supports tables with nested inheritance and declarative partitioning.

The accuracy of approximate_row_count depends on the database having up-to-date statistics about the table or hypertable, which are updated by VACUUM, ANALYZE, and a few DDL commands. If you have auto-vacuum configured on your table or hypertable, or changes to the table are relatively infrequent, you might not need to explicitly ANALYZE your table as shown below. Otherwise, if your table statistics are too out-of-date, running this command updates your statistics and yields more accurate approximation results.

Samples

Get the approximate row count for a single hypertable.

ANALYZE conditions;

SELECT * FROM approximate_row_count('conditions');

The expected output:

approximate_row_count
----------------------
               240000

Required arguments

Name Type Description
relation REGCLASS Hypertable or regular $PG table to get row count for.