Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: count(*) v. count(pk)
Select count(*) DOES NOT always use a full table scan. For example, I have
a table with approximately 14M rows, a primary key, and multiple indexes,
including several bitmap indexes. If I do a select count(*) on that table,
it does does a full index scan on one of the bitmap indexes and returns the
result in about 1 second.
Venkat wrote in message <6i2ln3$h91_at_dfw-ixnews9.ix.netcom.com>...
>>1) Is this in fact true (that a count(*) always does a full table scan)?
>**** Yes count(*) always does a FTS
>
>>2) Isn't counting on the primary key an impossibility if the key is
>comprised
>>of multiple columns?
>
>**** No. You can do SELECT COUNT(ename||empno) from emp;
>
>>3) Can anyone suggest any other method for quickly retieving total rows
>from
>>large, multi-column-PK tables?
>
>**** If you keep your statistics upto-date a simple solution would be query
>the dba_tables to see the number of rows. Analyze your tables and then
>query the num_rows column of dba_tables.
>
>HTH
>Venkat
>
>
>
Received on Wed Apr 29 1998 - 11:49:01 CDT
![]() |
![]() |