Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Why DISTINCT is costly?

Re: Why DISTINCT is costly?

From: <xhoster_at_gmail.com>
Date: 12 Sep 2005 19:01:55 GMT
Message-ID: <20050912150155.201$da@newsreader.com>


"Dan Koren" <dankoren_at_yahoo.com> wrote:
> <juhunu_at_gmail.com> wrote in message
> news:1126507505.386016.211310_at_f14g2000cwb.googlegroups.com...
> > 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.

I think that changing the second occurence of "foo" in your query into "bar" should do it.

> >
>
> And how else would one be able to
> eliminate duplicates without sort
> unique?

How about by using a hash? Oracle had become so hash-happy in version 9 (for joins), I don't know why they don't consider using hashes for "distinct" (and "group by") also. Or maybe 10g does consider them.

Anyway, I sometimes drop the distinct from the SQL and implement it on the "client" side using a hash (in Perl).

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB
Received on Mon Sep 12 2005 - 14:01:55 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US