Originally posted by Newton
It is Proven fact that the Count(PK) is faster than Count(*) ... Not a big difference the reason is PK_Column hav the index and this was it retrieves the data faster.
Cite the study where this proof exists, if you would, because I've yet to see it. In all my testing, count(*), count(ROWID), count(1), count(col) are all absolutely equal.

And just to get on my ever-present soap-box for a moment:

I am absolutely amazed at 2 contradictory issues I have found to be true:

- Most people who write SQL and/or PL/SQL actually know very little about how to truly optimize them.

- Almost everybody has an opinion on how to write count(*)

Is anybody else struck by the irony here? Something as incredibly unimportant as how to write count(*) holds *everyone's* interest, yet I'd be willing to bet money that at least 75% of the projects out there do something like this with it:

SELECT COUNT(*) INTO l_Count FROM .......

IF ( l_Count > 0 ) THEN ....

I see this *all the time*! People do a count of every single record when all they really want to know is if one *exists*

The statement *should* be:

SELECT COUNT(*) INTO l_Exists FROM ... WHERE ...
AND ROWNUM = 1

or COUNT(1) or COUNT(ROWID) or whatever makes you happy. The addition of the ROWNUM predicate is going to make a difference. What is inside the COUNT() will not.

Rant over ( over 4 weeks and no cigarrettes - can you tell? )

- Chris

BTW - another thought on the subject - I would personally not use ROWID. This would simply be in keeping with my position that ROWID should never appear in production application code.