COUNT(*) vs. COUNT(1) vs. COUNT(pk): which is better?
Posted
by zneak
on Stack Overflow
See other posts from Stack Overflow
or by zneak
Published on 2010-04-26T01:10:49Z
Indexed on
2010/04/26
1:13 UTC
Read the original article
Hit count: 289
Hello guys,
I often find these three variants:
SELECT COUNT(*) FROM Foo;
SELECT COUNT(1) FROM Foo;
SELECT COUNT(PrimaryKey) FROM Foo;
As far as I can see, they all do the same thing, and I find myself using the three in my codebase. However, I don't like to do the same thing different ways. To which one should I stick? Is any one of them better than the two others?
© Stack Overflow or respective owner