News for hackers. Stuff that matters.
Re:Use SQL subqueries to count distinct 50x faster by pradocchia on Friday January 24, 2014 @11:03AM (#7115532)
I agree with everything you've said, however I want to add that the general technique of compressing your data through pre-aggregation is a sound one, whether it is performed auto-magically by the optimizer, or manually through whatever hooks your DMBS provides.
Re:Use SQL subqueries to count distinct 50x faster by bentcorner on Friday January 24, 2014 @12:48PM (#7116217)
While it's hard to deny the results, the human readability of the final solution leaves a lot to be desired, especially for SQL casuals.
Re:Use SQL subqueries to count distinct 50x faster by calinet6 on Saturday January 25, 2014 @09:36AM (#7120875)
At least with Postgres (and MySQL to some degree, but Postgres is probably a better launching point), you could hack the query optimizer to handle situations like this if you really wanted to. I like to think this is how Postgres would like you to approach the problem, instead of creating a less comprehensible query.