pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Andrei Lepikhov <lepihov@gmail.com>
Cc: Илья Жарков <izharkov1243@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Cc: p.petrov@postgrespro.ru
Subject: Re: Do not scan index in right table if condition for left join evaluates to false using columns in left table
Date: Sat, 07 Dec 2024 22:11:22 -0500
Message-ID: <3543367.1733627482@sss.pgh.pa.us> (raw)
In-Reply-To: <prmcdabei4jl24v7ubbd6rdwjwh4e2c3zgycq6nyxt3m5zo3qx@mz2i6l6r4jdv>
References: <CAKE=rqQ-LHuh2eVsKC7ihkRJoCBZafSR72o3Xk4Xb=LcQMQfsA@mail.gmail.com>
	<tx2q6qi4hn2diocmnwfjo5xw2m56iabz3fyeimk7oeyymy3u4b@4ria2zwtz5mp>
	<3510224.1733609212@sss.pgh.pa.us>
	<lqgxfkrngt6zh6ldwiw6nkcanrcxn5sravsoum6r6s7xfc3oib@tcknx7ngik3l>
	<3517444.1733613195@sss.pgh.pa.us>
	<07d035c5-0e40-45ee-9c78-60a5dc6e9fae@gmail.com>
	<prmcdabei4jl24v7ubbd6rdwjwh4e2c3zgycq6nyxt3m5zo3qx@mz2i6l6r4jdv>

Andres Freund <andres@anarazel.de> writes:
> On 2024-12-08 09:23:42 +0700, Andrei Lepikhov wrote:
>> I think avoiding touching a hash table and an index under MergeJoin can also
>> be beneficial.

> How would you get significant wins for mergejoins? You need to go through both
> inner and outer anyway?

Yeah, sounds like nonsense to me too.  The reason this can be a win
for nestloop is that we perform a new scan of the inner relation
for each outer row, and if we can skip an inner scan altogether
then we're ahead.  But mergejoin and hashjoin only scan each input
once anyway, so I see no opportunity to save any scan work.

It's barely possible that this is interesting for hash join
because you could save scanning a hash list ... but frankly
I don't believe there could be enough win there to justify
additional mechanism.  Hash join is in a world of hurt already
if there are lots of duplicate hash codes.

			regards, tom lane





view thread (23+ messages)  latest in thread

Message-ID: <3543367.1733627482@sss.pgh.pa.us>
Permalink:  ../3543367.1733627482@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3543367.1733627482@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, andres@anarazel.de, lepihov@gmail.com, izharkov1243@gmail.com, p.petrov@postgrespro.ru
  Subject: Re: Do not scan index in right table if condition for left join evaluates to false using columns in left table
  In-Reply-To: <3543367.1733627482@sss.pgh.pa.us>
  References: <CAKE=rqQ-LHuh2eVsKC7ihkRJoCBZafSR72o3Xk4Xb=LcQMQfsA@mail.gmail.com> <tx2q6qi4hn2diocmnwfjo5xw2m56iabz3fyeimk7oeyymy3u4b@4ria2zwtz5mp> <3510224.1733609212@sss.pgh.pa.us> <lqgxfkrngt6zh6ldwiw6nkcanrcxn5sravsoum6r6s7xfc3oib@tcknx7ngik3l> <3517444.1733613195@sss.pgh.pa.us> <07d035c5-0e40-45ee-9c78-60a5dc6e9fae@gmail.com> <prmcdabei4jl24v7ubbd6rdwjwh4e2c3zgycq6nyxt3m5zo3qx@mz2i6l6r4jdv> <3543367.1733627482@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