tag:blogger.com,1999:blog-16959946.post4632373858960460001..comments2023-12-09T16:44:47.897+01:00Comments on The Data Charmer: DISTINCT? Don't be lazy!Giuseppe Maxiahttp://www.blogger.com/profile/15801583338057324813noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-16959946.post-31852404315923353622008-03-03T17:54:00.000+01:002008-03-03T17:54:00.000+01:00Nobody taught me to distrust DISTINCT, unfortunate...Nobody taught me to distrust DISTINCT, unfortunately. I learned it myself, though, a couple weeks ago, when I rewrote a query to remove the DISTINCT and it went from 35 seconds to 0.01 seconds.izenmaniahttps://www.blogger.com/profile/11196583962256309122noreply@blogger.comtag:blogger.com,1999:blog-16959946.post-73531535934599282922008-03-03T15:34:00.000+01:002008-03-03T15:34:00.000+01:00Hi Giuseppe, good post! When I learned SQL, our te...Hi Giuseppe, <BR/><BR/>good post! <BR/><BR/>When I learned SQL, our teacher taught us to distrust DISTINCT. Nine out of ten times, DISTINCT is a tell-tale for an underlying problem just like you describe here. And if you really do need to report distinct occurrences out of a list of duplicates, you are either cleansing rotten data or you are doing an aggregate query (in which case you should use GROUP BY). <BR/><BR/>So DISTINCT really has no business in a normal sensible query.<BR/><BR/>Personally, I feel about the same about UNION. I have never had to write UNION - I always write UNION ALL.rpboumanhttps://www.blogger.com/profile/13365137747952711328noreply@blogger.comtag:blogger.com,1999:blog-16959946.post-92197930397180933092008-03-03T10:41:00.000+01:002008-03-03T10:41:00.000+01:00Arjen,Thanks for the reminder. In my travel to Aus...Arjen,<BR/>Thanks for the reminder. In my travel to Australia I have seen the explanation of koalas non-laziness several times. So I know that they are not ethically lazy, but they are <A HREF="http://wordnet.princeton.edu/perl/webwn?s=lazy" REL="nofollow">disinclined to work or exertion</A> for lack of energy to spend.<BR/>So, no offense was intended.<BR/>It's just that the picture is so cute!<BR/><BR/>Cheers<BR/><BR/>GiuseppeGiuseppe Maxiahttps://www.blogger.com/profile/15801583338057324813noreply@blogger.comtag:blogger.com,1999:blog-16959946.post-75673839478988766722008-03-03T10:22:00.000+01:002008-03-03T10:22:00.000+01:00Since you use a picture of a koala in the context ...Since you use a picture of a koala in the context of "lazy", I should note that koalas are not actually lazy.<BR/>Their sole food (eucalyptus leaves) from which they extract both their regular nutrition and water needs, does not provide them with much energy. This is why they sleep most of the time, and feel no particular need to run around.<BR/><BR/>And since there will be Americans reading this, I should also note that koalas are NOT bears. They are no relation whatsoever.<BR/>This contrary to the dropbear, which also roams the Australian trees; one should definitely watch out for those.Anonymousnoreply@blogger.com