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: Merge join and sorts

Re: Merge join and sorts

From: Jonathan Lewis <jonathan_at_jlcomp.demon.co.uk>
Date: Wed, 9 Jan 2002 10:52:08 -0000
Message-ID: <1010573563.23917.0.nnrp-01.9e984b29@news.demon.co.uk>

Merge join does NOT 'always' use sort, it merely merges streams of sorted data.
It often happens to be the case that the two sets of data are generated unsorted and
therefore need to be sorted prior to merge.

However, it is perfectly feasible that
the fastest way of acquiring a set of
data is to access it through an index -
which could conceivably leave it correctly sorted for the merge. The question, therefore, was:

    Why, when both streams have been acquired     in a fashion that guarantees they are both     sorted suitably for merging, does Oracle still     apply a sort operation to the second stream ?

--
Jonathan Lewis
http://www.jlcomp.demon.co.uk

Now running 3-day intensive seminars
http://www.jlcomp.demon.co.uk/seminar.html

Host to The Co-Operative Oracle Users' FAQ
http://www.jlcomp.demon.co.uk/faq/ind_faq.html

Author of:
Practical Oracle 8i: Building Efficient Databases


Alex Filonov wrote in message <3C3BDC94.70589908_at_pro-ns.net>...

>
>Answer to your question: Merge join uses sort. Always. If you want to know
why,
>read something about sort algorithms, Knuth for example.
>I don't understand hints though. If you want merge join, index search just
>makes it slower, much slower, about 3 times. If you want to use index scan
on
>join fields, either remove all hints or use only one index hint, on the
smaller
>table. The most efficient algorithm here would be full table scan on bigger
>table and index scan on a smaller one.
>
Received on Wed Jan 09 2002 - 04:52:08 CST

Original text of this message

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