Is there ever a case where `SELECT COUNT(*)` would return a different result in `SELECT COUNT(something)` assuming no group by clause? I'm curious why they generate different query plans on virtually every backend.
That explains some of it. But how about the difference between `SELECT COUNT(*) FROM users` vs `SELECT COUNT(users.*) FROM users`, which still produces a different query plan, and returns the same value even if all columns are null
-
-
Interesting. I'd have to read a lot more into it to find that one.
-
I suspect the answer is "because fuck you don't do that", but it's a performance detail that I specifically had to work around in Diesel (like 2 years ago) so I'm quite curious if there's an actual technical reason. (I'm updating the docs for count is why I was thinking abt this)
- 9 more replies
New conversation -
-
-
Best guess though is ID gets it
-
I'm not sure what that means
- 2 more replies
New conversation -
-
-
Good question. I've only used `SELECT COUNT(table.*)` where `table` is on the right hand side of an outer join (e.g. a has_many), and there *does* take "all NULLs" into account properly
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.