Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Would Oracle use index on count(*)?
aa wrote:
>
> When I issue an Select count(*) from Table, Oracle always performs a table
> scan even though an index is available. In MS SQL Server, the optimizer will
> chose to scan the index (if one is available) instead of the table. Why
> doesn't Oracle do this?
If you use a count(*) the full table scan is coosen. If you use
count(primary key field)
an index scan shoud be used. I don't know the exact Oracle internals for
this, but
i think one reason is to make the codeing simple (e.g. what do you do
when there
are several indexes but none is unique, or even indexes with null value
??)
Received on Tue Apr 14 1998 - 03:17:45 CDT