Re: Simple query not using index: why?

From: Joshua Drake <jd(at)commandprompt(dot)com>
To: William Garrison <postgres(at)mobydisk(dot)com>
Cc: Adrian Klaver <aklaver(at)comcast(dot)net>, Postgres General List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Simple query not using index: why?
Date: 2008-09-03 20:01:30
Message-ID: 20080903130130.0a9ba092@jd-laptop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 03 Sep 2008 15:55:17 -0400
William Garrison <postgres(at)mobydisk(dot)com> wrote:

> So I expected scanning the index was faster, and still had everything
> it needed to do the count. Or perhaps it was because I said COUNT(*)
> so it needs to look at the other columns in the table? I really just
> wanted the number of "hits" not the number of records with distinct
> values or anything like that. My understanding was that COUNT(*) did
> that, and didn't really look at the columns themselves.

We do not have visibility information in the index, so we have to scan
the pages to see what tuples are live or dead (and thus count them).

Sincerely,

Joshua D. Drake

--
The PostgreSQL Company since 1997: http://www.commandprompt.com/
PostgreSQL Community Conference: http://www.postgresqlconference.org/
United States PostgreSQL Association: http://www.postgresql.us/
Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tony Caduto 2008-09-03 20:07:13 Re: Oracle and Postgresql
Previous Message William Garrison 2008-09-03 19:55:17 Re: Simple query not using index: why?