Re: COUNT(*) and index-only scans

From: Thom Brown <thom(at)linux(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: COUNT(*) and index-only scans
Date: 2011-10-10 17:34:02
Message-ID: CAA-aLv6-bWVgxLkxQKgwOFrV+CmxWtKwtFzpOOhM_fx6BWsqaQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 10 October 2011 18:23, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> I talked to Robert Haas and he said that index-only scans do not
> optimize COUNT(*).  Is this something we can do for PG 9.2?  Is anyone
> working on this?

Yes it does, provided that there is an appropriate WHERE clause. But
yes, I think we definitely want this if it's relatively easy. In
addition to this, it's not always easy to get it to use an index-only
scan even if it's going to significantly faster. I'm assuming some
supporting planner work needs to be added too.

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2011-10-10 17:35:17 Re: COUNT(*) and index-only scans
Previous Message Jeff Davis 2011-10-10 17:31:09 Re: Range Types - typo + NULL string constructor