Re: Strange logic for partial index proving

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: laser <laser(at)toping(dot)com(dot)cn>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Strange logic for partial index proving
Date: 2005-06-23 15:54:53
Message-ID: 20050623155453.GA14442@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jun 23, 2005 at 16:13:24 +0800,
laser <laser(at)toping(dot)com(dot)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.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Fuhr 2005-06-23 16:19:39 Re: plpgsql constraint checked data fails to restore
Previous Message Jan Wieck 2005-06-23 15:47:37 Re: plpgsql constraint checked data fails to restore