BUG #14011: select count(distinct column) does not utilizes indices to improve performance

Поиск
Список
Период
Сортировка
От gtakahashi@palantir.com
Тема BUG #14011: select count(distinct column) does not utilizes indices to improve performance
Дата
Msg-id 20160310043327.8903.60230@wrigleys.postgresql.org
обсуждение исходный текст
Ответы Re: BUG #14011: select count(distinct column) does not utilizes indices to improve performance  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
The following bug has been logged on the website:

Bug reference:      14011
Logged by:          Glen Takahashi
Email address:      gtakahashi@palantir.com
PostgreSQL version: 9.3.6
Operating system:   Red Hat Enterprise Linux 6.7
Description:

Doing a select count(distinct column) does not utilize indices and takes a
very long time to compute.
For example

Create table test_table (number integer);
Create index on test_table (number);
Insert into test_table (number) select generate_series(1,100000); (I did
this ~500 times to replicate the scale of data we have)
Select count(distinct number) from test_table;
Count 100000 Time: 63419.600ms
Select count(1) from (select distinct number from test_table) a;
Count 100000 Time: 10743.186 ms

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

Предыдущее
От: Breen Hagan
Дата:
Сообщение: Re: BUG #13755: pgwin32_is_service not checking if SECURITY_SERVICE_SID is disabled
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #14011: select count(distinct column) does not utilizes indices to improve performance