Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Why DISTINCT is costly?
sim wrote:
> A group by is not always the better choice but in most cases you can
> see it's better when you look at the explain plan of your query.
> Here's an example:
<snp/>
> Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
>
> SELECT STATEMENT Optimizer Mode=ALL_ROWS 8 K 26,6206304779564
>
> SORT GROUP BY 8 K 733 K 26,6206304779564
> EXTERNAL TABLE ACCESS FULL DWH_REA.EXT_TDVC_VERTRAG 8 K 733
> K 24,4384919334481
>
>
> Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
>
> SELECT STATEMENT Optimizer Mode=ALL_ROWS 8 K 201,302378376216
>
> SORT UNIQUE 8 K 733 K 201,302378376216
> EXTERNAL TABLE ACCESS FULL DWH_REA.EXT_TDVC_VERTRAG 8 K 733
> K 24,4384919334481
There's not much difference in those plans. Do you have an explanation why SORT GROUP BY is cheaper than SORT UNIQUE in this case? Thx!
Kind regards
robert Received on Mon Sep 12 2005 - 07:47:11 CDT