From: gtakahashi@palantir.com
To: pgsql-bugs@postgresql.org
Subject: BUG #14011: select count(distinct column) does not utilizes indices to improve performance
Date: Thu, 10 Mar 2016 04:33:27 +0000
Message-ID: <20160310043327.8903.60230@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: gtakahashi@palantir.com
Subject: Re: BUG #14011: select count(distinct column) does not utilizes indices to improve performance
In-Reply-To: <20160310043327.8903.60230@wrigleys.postgresql.org>
References: <20160310043327.8903.60230@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox