
Finding Row Count for All Tables in PostgreSQL Database
The post discusses the effectiveness of two concepts for counting rows in PostgreSQL: using table statistics versus executing the SELECT COUNT(*) command. While table statistics offer faster row estimates with minimal resource consumption, accuracy can be hindered if the statistics are outdated. In contrast, SELECT COUNT(*) provides exact counts but incurs substantial performance penalties, especially with large tables. Testing with the Adventureworks database shows that for retrieving counts of all tables relying statistics collector or mimicking the planner’s logic can be significantly more efficient than direct queries.





