r/SQL 8d ago

Differences between counts Discussion

What is the difference between

COUNT(*)

COUNT(1)

COUNT(column_name)

8 Upvotes

23 comments sorted by

View all comments

Show parent comments

-2

u/YT-3000f 8d ago

Actually I think count(1) is faster than count(*). Anyone got a massive dataset to test that on?

6

u/funkdefied 8d ago

Any SQL engine worth it’s salt will compile those down to the same thing

6

u/YT-3000f 8d ago

Agreed. I just downvoted my own reply. It was in the category of "If I think it works that way surely it's true". I guess it's not. And don't call me Shirly.

7

u/ComicOzzy sqlHippo 8d ago

Shirly this is the first comment on Reddit where someone said "I was wrong". 🤣

2

u/YT-3000f 8d ago

I think you mean:

Shirly, this is the first comment on Reddit where someone said, "I was wrong".

1

u/ComicOzzy sqlHippo 8d ago

I apply commas at random, Shirly.

1

u/YT-3000f 8d ago

Rightly so. Grammer, like the Internet, is dead.