Thursday, March 26, 2009


For years I've heard folks promote the idea that COUNT(1) is better then COUNT(*). This is not true, and I'm pretty sure this has never been true. Here is a very simple test in If some one can prove to me that this works different in a different version of Oracle, please let me know.

Here is a count(*):

Here is count of a constant:

Both plans do exactly the same thing, a fast full index scan on the primary key column of the table. Oracle will use an index on a non-null column for the count, it doesn't have to be the primary key.

No comments:

Post a Comment