3 ms·
Yeah, if you have the ID's as null. But why you would do such thing in the first place? Have the ID be "serial primary key" and you'll never have null values in
by unnouinceput 5y ago
Yeah, if you have the ID's as null. But why you would do such thing in the first place? Have the ID be "serial primary key" and you'll never have null values in there ever!
Btw, that's the second optimization you learn. So you telling me that in your case, you have null values in your ID's? You should be fired trice then.
Since you're hell bent on doing tests, do one with a dozen millions rows, just ID and a varchar as columns, and in one case have the ID have nulls, and in the other case be like I said. Then see the difference when you run "select count(ID) where the_varchar_column = 'Steve'" vs "select(star_sign) bla bla" and come back to me. Image would be appreciated. Then go rewrite your DB structure and the query when you realize the performance
- option_greek 5y agoI'm not sure what value your harsh tone adds to your comment. Sharing experiences like this publicly benefits everyone. It obviously exposes blindspots in one's knowledge and it is expected that noone knows everything. That is the point of the. Comments functionality in HN. So that we can all share things that we know and absorb things we don't. I personally enjoyed this article and learnt a few things from it. I learnt a few things from your comment too but it would have been better without all the harsh words.
- cube2222 5y agoI've never said I have null values, I've just used it to explain what performance optimization opportunities COUNT(*) has vs COUNT(id). It would be great if you'd explain why what I've written is not the case or provided some citation for that.
- deleted 5y ago[deleted]