How to speed up the counting of all lines in PostgreSQL v9.3.11?

The main WHERE that WHERE supported.

Now download speed: 2.9424 sec. (324477 records)

Request :

 SELECT COUNT("my_field") FROM "mytable"; 

I already looked at estimate , and creating a table to write count rows through INSERT + DELETE triggers. But all this does not fit, since there must be a sorting on the page, so WHERE important, and in the estimate and other methods I do not know how to use it.

Please tell me how to speed up the counting of rows in the table, taking into account the WHERE ?

  • wiki.postgresql.org/wiki/Slow_Counting it is the most - SanŚ́́́́́́́́́́́́
  • does not fit at all, I read it - Neatek
  • four
    And why count ("my_field") you really need to know how many values ​​in this column are not null. See the execution plan. For the where clause, an index must exist. And you need to write count (1) if you need exactly the number of lines and not null values - Mike

0