Hacker News new | ask | show | jobs
by jletienne 976 days ago
whenever I see [select distinct ... group by] , i know i'm in for some bs. the original code creator had some duplication/cartesians but never properly addressed it
2 comments

I’ve done it a few times in the app I’m working with and had no idea DISTINCT was not the proper way to address it. I mean, it’s a standard feature, named « distinct », easy to use and it works. It’s on me that I didn’t run an explain on these queries, but it seems like an easy mistake to make.

Anyway I’ll happily fix these in my code on Monday.

Seeing distinct being abused in application code is pretty rare though. What gets me is seeing it in some ETL or data analyst's queries. That's the sign that you're about to spend the next hour unfucking a query with like 50 joins and no CTEs for organization, written by someone who has no understanding of the underlying schema.