Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

count(*) or count(rowid) 1

Status
Not open for further replies.

hubud

Instructor
Oct 18, 2002
123
GB
Have been told that using count(*) is slower and uses more resources than count(rowid).
Having run a number of counts on a large table it appears that the timings are all over the place. This is probably due to other processes running when I do the tests.
What are the backgrounds reasons for this, and are they valid. I am trying to speed up selects as part of procedures and would be interested in any ideas as the whether they're worth changing.

simmo
 
As long as there is an index on the table, I think you will get the same results:

09:01:00 SQL> select count(rowid) from gl_je_headers;

COUNT(ROWID)
------------
51421


Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=138 Card=1 Bytes=7)
1 0 SORT (AGGREGATE)
2 1 INDEX (FULL SCAN) OF 'GL_JE_HEADERS_U1' (UNIQUE) (Cost=1
38 Card=51270 Bytes=358890)




09:01:16 SQL> select count(*) from gl_je_headers;

COUNT(*)
----------
51421


Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=138 Card=1)
1 0 SORT (AGGREGATE)
2 1 INDEX (FULL SCAN) OF 'GL_JE_HEADERS_U1' (UNIQUE) (Cost=1
38 Card=51270)
 
cheers turkbear, that is a very useful link

simmo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top