Re: Condition pushdown: why (=) is pushed down into join, but BETWEEN or >= is not?

From: "Finnerty, Jim" <jfinnert(at)amazon(dot)com>
To: Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
Cc: Justin Pryzby <pryzby(at)telsasoft(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dmitry Astapov <dastapov(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Condition pushdown: why (=) is pushed down into join, but BETWEEN or >= is not?
Date: 2022-02-17 18:55:06
Message-ID: C83D5E20-0639-40AE-AF36-42AEC6F9A702@amazon.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

So I think knowing what bad it is to have this feature is the key point to discussion now.

> While I've only read your description of the patch not the patch itself,

This comment applies to me also.

Is the join selectivity properly calculated in all cases, e.g. in the n:m join case in particular, or in general when you’re not joining to a unique key? (this would be the usual situation here, since it adds a range qual to a join qual)

>> Furthermore, there are some cases involving parameterized paths where
>> enforcing the inequality multiple times is definitely bad

* This has been done by committing 4.

What remaining cases are there where the qual is evaluated redundantly?

* Anyone still have interest in this? Or is a better solution really possible?
Or is the current method too bad to rescue?

As you’ve shown, this can potentially be very important, though I don’t think you’ll often see equijoins with an additional range restriction on the join keys. When it happens, though, it could be especially important for joins to partitioned tables with many remote fdw partitions when the join can’t be pushed down to the remote server.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2022-02-17 18:55:32 Isn't gist_page_items broken for opclasses with compress methods?
Previous Message Andres Freund 2022-02-17 18:33:03 Re: Nonrandom scanned_pages distorts pg_class.reltuples set by VACUUM