Re: Why count(*) doest use index? - Mailing list pgsql-general

From Alban Hertroys
Subject Re: Why count(*) doest use index?
Date
Msg-id 1B34B94E-1A19-400C-9BCE-627227420760@solfertje.student.utwente.nl
Whole thread Raw
In response to Re: Why count(*) doest use index?  (Allan Kamau <kamauallan@gmail.com>)
List pgsql-general
On 6 Mar 2011, at 9:03, Allan Kamau wrote:

> If this is true it seems that the primary key and perhaps other unique
> indexes do indeed contain exact details of the uniqueness of the
> persisted tuples of a given relation at any given time.

That is true within a single transaction, but indexes contain information about ALL active transactions. Because of
thatthe contents of the indexes are not guaranteed to be unique and it's possible they contain references to rows that
arenot visible to the current transaction. 

> Or am I missing a crucial point.


Yup, you're missing the effects of concurrency.

Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll see there is no forest.


!DSPAM:737,4d7365c5235885600661482!



pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: Why count(*) doest use index?
Next
From: Alexander Farber
Date:
Subject: Copying few tables from one database to another