How do I speed up counting rows in a PostgreSQL table?

前端 未结 6 922
悲哀的现实
悲哀的现实 2020-12-02 18:37

We need to count the number of rows in a PostgreSQL table. In our case, no conditions need to be met, and it would be perfectly acceptable to get a row estimate if that sig

6条回答
  •  臣服心动
    2020-12-02 19:19

    You can get an estimate from the system table "pg_stat_user_tables".

    select schemaname, relname, n_live_tup 
    from pg_stat_user_tables 
    where schemaname = 'your_schema_name'
    and relname = 'your_table_name';
    

提交回复
热议问题