difference between count(*) and count(1)
difference between count(*) and count(1)
Collapse
X
-
Tags: None
-
-
Hi,
Both perform the same function, to get the number of rows returned by the query.
But performance wise count(1) is better as count(*) retrieves all columns and counts the rows, where as count(1) retrieves 1's whenever a row is there.
CheersComment
-
Tom Kyte said about it correctly, there was a version where it did make a difference (6, early 7 maybe) and thus a myth was born. According to Tom, the parser is now coded so that count(1) and count(*) use exactly the same code path so any differences you see between the two would occur on multiple runs of the same statement, i.e. they are caused by external events.Originally posted by frozenmistHi,
Both perform the same function, to get the number of rows returned by the query.
But performance wise count(1) is better as count(*) retrieves all columns and counts the rows, where as count(1) retrieves 1's whenever a row is there.
CheersComment
Comment