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 -> count(*) v. count(pk)

count(*) v. count(pk)

From: <brendan_o'brien_at_wrightexpress.com>
Date: Mon, 27 Apr 1998 11:45:19 -0600
Message-ID: <6i2cn9$u1h$1@nnrp1.dejanews.com>


Hi folks.

Saw a post recently where someone recommended doing a count(pk) instead of a count(*) as count(*) always does a full table scan.

Questions:

  1. Is this in fact true (that a count(*) always does a full table scan)?
  2. Isn't counting on the primary key an impossibility if the key is comprised of multiple columns?
  3. Can anyone suggest any other method for quickly retieving total rows from large, multi-column-PK tables?

I tested this theory on a table with 250,000 rows and a one-column PK using both queries, and got no difference in response time. I can think of no way to test this on a table with a 2+ column PK as count() accepts only one argument.

This isn't of prime importance, more to settle an internal debate here.

Thanks,
-Brendan

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading Received on Mon Apr 27 1998 - 12:45:19 CDT

Original text of this message

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