Reputation: 1714
According to the docs:
A SELECT expression using COUNT(*) returns the number of rows that matched the query. Alternatively, you can use COUNT(1) to get the same result.
Are there any performance benefits (as in RDBMSes) from using the latter approach?
Upvotes: 1
Views: 487
Reputation: 16410
There is no difference between COUNT(*) and COUNT(1). COUNT(1) is just for backwards compatibility I think with some older stuff. selectCountClause returns empty RawSelector list regardless of the contents, but if its a number and not 1 or not '*' it will throw an exception.
You might wanna avoid count in general if worried about performance. Instead use a counter or maintain count at higher level instead.
Upvotes: 5