0

I want to get the number of rows in all tables of a postgres database. I analyzed and found out ways like , count(*) for all tables - which seems very slow for larger tables. Reading statistics from pg_stat_user_tables - But that require 'vacuum' to be run on a database. Do we have better ways for finding this..I need to find the exact row count of all tables

Priya
  • 1,096
  • 4
  • 15
  • 32
  • 1
    The **only** way to get the _exact_ row is to use `select count(*)` –  Feb 26 '18 at 11:27
  • we can also do this by running vacuum on our database and then getting the count from statistics right. Sometimes vacuum also takes lots of time , so is there a possibility to find the row_count in some other ways – Priya Feb 26 '18 at 11:35
  • 1
    Again, the only way to get the **exact** row count is to use `select count(*)`. The row count `vacuum` "calculates" is still an estimate. –  Feb 26 '18 at 11:38
  • can you explain how is it approximate and I cannot use it when I want to get the exact count – Priya Feb 26 '18 at 12:41

0 Answers0