Search Postgresql Archives

Re: count(*) vs count(id)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I just ran a few practical tests on large (~14mil rows) tables that have multiple indexes.

SELECT COUNT(id) forces PostgreSQL to use the primary key index.
SELECT COUNT(*) allows PostgreSQL to chose an index to use and it seems to be choosing one of smaller size which leads to less IO and hence returns the result faster.


On Tue, Feb 2, 2021 at 3:45 PM Hellmuth Vargas <hivs77@xxxxxxxxx> wrote:


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux