Re: can't get rid of unnesesary SORT step in explain plan for hash join

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: alexey(at)price(dot)ru
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: can't get rid of unnesesary SORT step in explain plan for hash join
Date: 2001-05-14 14:17:09
Message-ID: 8987.989849829@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Alexey Nalbat <alexey(at)price(dot)ru> writes:
> While executing this query postgres at first creates hash on table
> "resellers", then get from index "products_mcr" for rows with
> "m_id=123" already ordered (!!!) pairs "c_id,r_id", for each that
> pair it checks join condition using hash. If postgers behaves like
> this then the result of this hash join is already sorted, and extra
> "Sort" is not needed.

No, because the hash step might choose to divide its processing into
multiple "batches", thereby destroying the sort order. The outer path's
ordering is preserved only in relatively small test cases...

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Ligia Pimentel 2001-05-14 14:28:18 fatal ERROR running simple join query...
Previous Message Sylte 2001-05-14 13:02:03 Auto incrementing an integer