Re: Selection of join algorithm

From: Amol Bhangdiya <amol(dot)b89(at)gmail(dot)com>
To: Ishaya Bhatt <ishayabhatt(at)gmail(dot)com>
Cc: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Selection of join algorithm
Date: 2014-03-08 15:35:05
Message-ID: CADaB4eBfBTySqGvh_4wvoDv62Eor3pZ28kZv7q8iYw7GSknW0w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

If you specify joining condition other than equality then nested loop join
is invoked.
Example Query : explain analyze select name from student,takes where
student.id > takes.id

If both the input to join is sorted on joining condition then merge join is
invoked.
Example Query: explain analyze select stud.name from (select id, name from
student order by id) stud,(select id,year from takes order by id) t where
stud.id = t.id

On Sat, Mar 8, 2014 at 7:50 PM, Ishaya Bhatt <ishayabhatt(at)gmail(dot)com> wrote:

> Hi,
>
> I am trying to analyze join performance. But I see that even for a table
> having 100,000 rows and join attribute as primary key, postgres always
> performs hash join.
>
> Can anyone please tell me under which conditions merge join or nested loop
> join is invoked?
>
> Thanks and Regards,
> Ishaya
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Rowan 2014-03-09 01:26:52 Trigger function
Previous Message Ishaya Bhatt 2014-03-08 14:20:48 Selection of join algorithm