Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1adsYq-00065B-3B for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Mar 2016 04:50:56 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1adsYp-00061n-At for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Mar 2016 04:50:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1adsYC-0005KV-IL for pgsql-bugs@postgresql.org; Thu, 10 Mar 2016 04:50:16 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1adsY5-0002Og-H5 for pgsql-bugs@postgresql.org; Thu, 10 Mar 2016 04:50:16 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u2A4o4kO007831; Wed, 9 Mar 2016 23:50:04 -0500 From: Tom Lane To: gtakahashi@palantir.com cc: pgsql-bugs@postgresql.org 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> Comments: In-reply-to gtakahashi@palantir.com message dated "Thu, 10 Mar 2016 04:33:27 +0000" Date: Wed, 09 Mar 2016 23:50:04 -0500 Message-ID: <7830.1457585404@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org gtakahashi@palantir.com writes: > Doing a select count(distinct column) does not utilize indices Nope, it does not. Don't hold your breath waiting for that to change; it might sometime, but nobody is working on it that I know of. You'd have better luck with a "SELECT count(*) GROUP BY column" type of query, I expect. (Most likely that won't use an index either, BTW, but it'll be smarter than count(distinct).) regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs