Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Would Oracle use index on count(*)?

Re: Would Oracle use index on count(*)?

From: Eugen Nyffeler <eugen.nyffeler_at_ubs.com>
Date: Tue, 14 Apr 1998 10:17:45 +0200
Message-ID: <35331BA9.86E49A6E@ubs.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US