On Thu, 10 Feb 2005 09:17:15 -0500, Mercadante, Thomas F <thomas.mercadante@(protected)> wrote: > David, > > Just try running an explain plan against your select count statement. Run > it against a table with a primary key, and one without one. Run it against > a table with a unique key but no primary key. > > What you will find is that Oracle will pick the quickest way to get the > result. If there is a PK or Unique Key, it will scan the index - because > the column is NOT NULL, it will have an entry for every row. > > If the table does not have any unique index to use, it will count the rows > in the table.
on a similar note it will make use of a bitmap index and potentially return the result very fast on very large tables if it can. user @ orcl>drop table t1;
Table dropped.
user @ orcl>create table t1 2 as 3 select rownum id,a.* 4 from all_objects a, all_objects b 5* where rownum < 1000001;