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.