Re: count(*) vs count(id)

Поиск
Список
Период
Сортировка
От Cherio
Тема Re: count(*) vs count(id)
Дата
Msg-id CAKHqFkKWVam7LyVM7bxDMXxsr4fZVbNuTG=rfHx07jpF5f6MMA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: count(*) vs count(id)  (Hellmuth Vargas <hivs77@gmail.com>)
Ответы Re: count(*) vs count(id)  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Список pgsql-general
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@gmail.com> wrote:

В списке pgsql-general по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: permission denied to create and drop user
Следующее
От: Sebastian Dressler
Дата:
Сообщение: Re: Foreign table performance issue / PostgreSQK vs. ORACLE