Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Why DISTINCT is costly?
juhunu_at_gmail.com wrote:
: Whenever I use a DISTINCT in my query, I see the "SORT UNIQUE" getting
: added to the execution plan.
: "SORT UNIQUE" is increasing the cost of the query by a greater factor.
: Any help in reducing the cost in using DISTINCT would be of much help.
: Thanks in Advance.
It's hard for a program to get distinct values without having a sorted list available. How else will it determine whether a value is distinct or not? E.g. the way to get a unique list of lines in unix is typically to "sort file | uniq" .
Having an index that is already a sorted list of the desired values would presumably help.
-- This programmer available for rent.Received on Mon Sep 12 2005 - 02:13:42 CDT