How do you find the row count for all your tables in Postgres

前端 未结 15 2310
无人及你
无人及你 2020-11-22 12:31

I\'m looking for a way to find the row count for all my tables in Postgres. I know I can do this one table at a time with:

SELECT count(*) FROM table_name;
         


        
15条回答
  •  礼貌的吻别
    2020-11-22 13:01

    If you don't mind potentially stale data, you can access the same statistics used by the query optimizer.

    Something like:

    SELECT relname, n_tup_ins - n_tup_del as rowcount FROM pg_stat_all_tables;
    

提交回复
热议问题