pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <david.rowley@2ndquadrant.com>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: Simon Riggs <simon@2ndquadrant.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: Performance improvement for joins where outer side is unique
Date: Fri, 11 Mar 2016 16:32:58 -0500
Message-ID: <13653.1457731978@sss.pgh.pa.us> (raw )
In-Reply-To: <CAKJS1f-qN8NVT456XT6-NW+Vc_n0-jfCVtaQio0JoOWzP6F2ig@mail.gmail.com >
References: <20150320.121140.148610378.horiguchi.kyotaro@lab.ntt.co.jp >
<CAPpHfdviphQFjk-gaGZGGxLAyt=YuVdJLnntsxOKnU296s9u-Q@mail.gmail.com >
<CAKJS1f-=1y0-f5FFV2_r7LtS+CL2Lw-nhJjXB3O_0FmBqnK=3A@mail.gmail.com >
<27152324.eFKJb4Khb5@dinodell >
<8608754a32d1325c2f83ba8b1df71585@xs4all.nl >
<55DA1F9F.5040204@2ndquadrant.com >
<CAKJS1f-9UTo6fA+h8rojd30CujSKscZamLn5YnKw5+ASbV0Wwg@mail.gmail.com >
<5085.1440375543@sss.pgh.pa.us >
<CAKJS1f_8hrzTDCu0pwERWj_dLZu-6DYFQJAtNT+vM6UeOn0kHw@mail.gmail.com >
<8907.1440383377@sss.pgh.pa.us >
<CAKJS1f8JCt15ngEP8sZO-JYYT8mS6HUP_CT0T6S_0ogk1kQt+Q@mail.gmail.com >
<CAKJS1f_4hm3qwKeHYKftd+BQuYBgdNR+rk+XP_JW9EY-ALHZbQ@mail.gmail.com >
<56718B15.6060507@2ndquadrant.com >
<CAKJS1f_i7dGh9ytc0DuaX3JJaN7Gp9AGXNbdtWjj0PkPzNzUeg@mail.gmail.com >
<5671FF0D.2010403@2ndquadrant.com >
<CANP8+j+vxfEf3dqhnzKAnDopnnUM-Zjb90gNT=haEQNQePj9Mw@mail.gmail.com >
<CAKJS1f8MpcL4_oS+n-vmnisd_8OMuZR2vyLETOF7ABSLk_iNZg@mail.gmail.com >
<56A25A72.2090505@2ndquadrant.com >
<CAKJS1f-V7xEh6+! YHrCRNaZzbk7mbgPvi9MdXTCD8eJ=ROuq2Mg@mail.gmail.com >
<24304.1457482780@sss.pgh.pa.us >
<CAKJS1f-qN8NVT456XT6-NW+Vc_n0-jfCVtaQio0JoOWzP6F2ig@mail.gmail.com >
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
So I started re-reading this thread in preparation for looking at the
patch, and this bit in your initial message jumped out at me:
> In all of our join algorithms in the executor, if the join type is SEMI,
> we skip to the next outer row once we find a matching inner row. This is
> because we don't want to allow duplicate rows in the inner side to
> duplicate outer rows in the result set. Obviously this is required per SQL
> spec. I believe we can also skip to the next outer row in this case when
> we've managed to prove that no other row can possibly exist that matches
> the current outer row, due to a unique index or group by/distinct clause
> (for subqueries).
I wondered why, instead of inventing an extra semantics-modifying flag,
we couldn't just change the jointype to *be* JOIN_SEMI when we've
discovered that the inner side is unique.
Now of course this only works if the join type was INNER to start with.
If it was a LEFT join, you'd need an "outer semi join" jointype which
we haven't got at the moment. But I wonder whether inventing that
jointype wouldn't let us arrive at a less messy handling of things in
the executor and EXPLAIN. I'm not very enamored of plastering this
"match_first_tuple_only" flag on every join, in part because it doesn't
appear to have sensible semantics for other jointypes such as JOIN_RIGHT.
And I'd really be happier to see the information reflected by join type
than a new line in EXPLAIN, also.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
view thread (131+ messages) latest in thread
Message-ID: <13653.1457731978@sss.pgh.pa.us>
Permalink: ../13653.1457731978@sss.pgh.pa.us/
Also on: postgresql.org/message-id/13653.1457731978@sss.pgh.pa.us
copy link · copy postgr.es
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-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, david.rowley@2ndquadrant.com, tomas.vondra@2ndquadrant.com, simon@2ndquadrant.com
Subject: Re: Performance improvement for joins where outer side is unique
In-Reply-To: <13653.1457731978@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