Re: Why is it not using an index? - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Why is it not using an index?
Date
Msg-id 20020315120934.Y54258-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Re: Why is it not using an index?  (Dmitry Tkach <dmitry@openratings.com>)
List pgsql-general
On Fri, 15 Mar 2002, Dmitry Tkach wrote:

> explain select count (x) from a ;
>
> Aggregate� (cost=100175934.05..100175934.05 rows=1 width=2)
> � ->� Seq Scan on a� (cost=100000000.00..100150659.04 rows=10110004 width=2)
>
> Am I missing something here again, or will it just not use an index
> for aggregation?

It won't for something like the above because it needs to test each row
to see if it's currently visible to your transaction (which involves
reading from the table file anyway) which means you end up reading the
entire table plus the index (and paying some costs in random access).
If the index had the transaction information the index would be usable
but there are issues about doing that as well (you might want to check
past messages - especially ones from Tom Lane - on the subject)



pgsql-general by date:

Previous
From: "Gregory Wood"
Date:
Subject: Re: Why is it not using an index?
Next
From: Fernando Schapachnik
Date:
Subject: Re: Database quota