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: count(*)

Re: count(*)

From: anil chada <anil.chada_at_oracle.com>
Date: 8 Apr 2002 09:05:45 -0700
Message-ID: <36503db6.0204080805.34f61fb7@posting.google.com>


Just a thought ...
If you have a primary key column in the table.. then doing

select count(primary_key_column)
from table;

would be faster, because then oracle will count the records in the index, rather than going through all the blocks related to the table..

correct me, if i am wrong..

Thanks
Anil

Norman Dunbar <Norman.Dunbar_at_lfs.co.uk> wrote in message news:<E2F6A70FE45242488C865C3BC1245DA701CDFE03_at_lnewton.leeds.lfs.co.uk>...
> Morten.
>
> remember that count may do a full table scan, so will read every data
> block up to the high water mark - regardless of whether the data block
> is empty or not. This means that if your table_b has had a lot of
> deletions don on it, then it may have a number of empty blocks and
> although the row count is the same, the tables are not identical.
>
> Check out http://www.ixora.com.au for details on some experimentation
> with count(*) and count(column) and you will see that it is probably
> running as quick as it can.
>
> Cheers,
> Norman.
>
> ------------------------------------------------------------------------
> -----
> Norman Dunbar EMail: Norman.Dunbar_at_LFS.co.uk
> Database/Unix administrator Phone: 0113 289 6265
> Fax: 0113 289 3146
> Lynx Financial Systems Ltd. URL: http://www.Lynx-FS.com
> ------------------------------------------------------------------------
> -----
>
>
> -----Original Message-----
> From: Morten Primdahl [mailto:morten_at_caput.com]
> Posted At: Monday, April 08, 2002 9:06 AM
> Posted To: server
> Conversation: count(*)
> Subject: count(*)
>
>
>
> Hi. What affects the execution speed of count(*):
> <SNIP>
Received on Mon Apr 08 2002 - 11:05:45 CDT

Original text of this message

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