pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: alexey@price.ru
Cc: pgsql-sql@postgresql.org
Subject: Re: can't get rid of unnesesary SORT step in explain plan for hash join
Date: Mon, 14 May 2001 10:17:09 -0400
Message-ID: <8987.989849829@sss.pgh.pa.us> (raw)
In-Reply-To: <01051413453300.13379@workshop.price.ru>
References: <01051118284600.06900@workshop.price.ru>
	<22028.989718836@sss.pgh.pa.us>
	<01051413453300.13379@workshop.price.ru>

Alexey Nalbat <alexey@price.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



view thread (4+ messages)

Message-ID: <8987.989849829@sss.pgh.pa.us>
Permalink:  ../8987.989849829@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/8987.989849829@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, alexey@price.ru
  Subject: Re: can't get rid of unnesesary SORT step in explain plan for hash join
  In-Reply-To: <8987.989849829@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox