Re: Strange logic for partial index proving - Mailing list pgsql-hackers

From Bruno Wolff III
Subject Re: Strange logic for partial index proving
Date
Msg-id 20050623155453.GA14442@wolff.to
Whole thread Raw
In response to Re: Strange logic for partial index proving  (laser <laser@toping.com.cn>)
List pgsql-hackers
On Thu, Jun 23, 2005 at 16:13:24 +0800, laser <laser@toping.com.cn> wrote:
> 
> This thread make me to think about the question:
> could this "feature" be used in select count(*) type
> query that force it to use index?

count(*) can already be helped by indexes, but probably not the way you think.
The count isn't saved anywhere, so each row needs to be checked to make sure
it is visible to the current transaction and that it satisfies any WHERE
conditions. The latter can sometimes be sped up using index scans (typically
if the matchin grows are less than 5% of the table or somewhat more if
the rows are clustered according to the index). If you are counting all
of the visible records in a table a sequential scan is going to be
the fastest plan.


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: regression failure
Next
From: Jan Wieck
Date:
Subject: Re: [GENERAL] plpgsql constraint checked data fails to restore