Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Why DISTINCT is costly?
Robert Klemme apparently said,on my timestamp of 14/09/2005 11:30 PM:
>
> Which one apart from the cost and the SORT GROUP BY vs. SORT UNIQUE. Did
> I overlook something?
IIRC, there was a significant difference in bytes processed? The text was a bit mangled due to wrapping, maybe I misread it.
>
>>But the best solution is always to avoid the DISTINCT.
Why they apply is simple: DISTINCT forces a unique sort, no matter what. You may be able to slightly speed the sort with indexes, but it ain't never gonna be as fast as joining to the necessary tables to avoid the duplicates in the first place.
If a join solves the problem one is trying to solve, then it is a preferable solution. There are a few examples around of this kind of design problem, I'll see if I can find some URLs for you.
-- Cheers Nuno Souto in sunny Sydney, Australia wizofoz2k_at_yahoo.com.au.nospamReceived on Wed Sep 14 2005 - 08:52:04 CDT