approx_count
Fast approximate row counts for tables and indexes in PostgreSQL 14+ from pg class.reltuples, with a governed ANALYZE refresh
approx_count · Fast approximate row counts for tables and indexes in PostgreSQL 14+ from pg class.reltuples, with a governed ANALYZE refresh
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 101278 | approx_count | approx_count | 1.0 | FUNC | Unknown | SQL |
Usage
Sources:
- Official upstream README
- Official extension control file (approx_count.control)
- Official extension SQL (approx_count–1.0.sql)
approx_count — Fast approximate row counts for tables and indexes in PostgreSQL 14+, read from pg_class.reltuples instead of disk-heavy exact COUNT(*) scans, with a governed ANALYZE refresh when the statistics go stale. Use it when SQL needs these specialized functions or aggregates. Use the pinned upstream revision linked above as the API boundary and test it on the target PostgreSQL build.
Core Workflow
Install the extension in the intended database, run the smallest upstream example above when available, and verify the installed version and returned values before integrating it into application SQL.
Important Objects
IFis a table installed or managed by the extension.
Requirements and Caveats
- The reviewed control file declares default version
1.0. - The control file marks the extension as non-relocatable.
- Confirm privileges, supported PostgreSQL versions, upgrade behavior, and failure cases against the pinned source before production use.