pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrey Lepikhov <a.lepikhov@postgrespro.ru>
To: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Clause accidentally pushed down ( Possible bug in Making Vars outer-join aware)
Date: Wed, 22 Feb 2023 12:48:45 +0600
Message-ID: <0b819232-4b50-f245-1c7d-c8c61bf41827@postgrespro.ru> (raw)

Hi,
sqlancer benchmark raised an issue with pushing down clauses in LEFT 
JOINs. Example:

DROP TABLE IF EXISTS t1,t2,t3,t4 CASCADE;
CREATE TABLE t1 AS SELECT true AS x FROM generate_series(0,1) x;
CREATE TABLE t2 AS SELECT true AS x FROM generate_series(0,1) x;
CREATE TABLE t3 AS SELECT true AS x FROM generate_series(0,1) x;
CREATE TABLE t4 AS SELECT true AS x FROM generate_series(0,1) x;
ANALYZE;

EXPLAIN (ANALYZE, COSTS OFF)
SELECT ALL t1.x FROM t1, t2
   LEFT OUTER JOIN t3
   ON t3.x
     LEFT OUTER JOIN t4
     ON t3.x
WHERE t4.x ISNULL;

We should get zero tuples, right? But we have the explain:
Nested Loop (actual time=0.024..0.028 rows=4 loops=1)
...

REL_15_STABLE works correctly. As I remember, it could be induces by new 
machinery, introduced by the 'Making Vars outer-join aware' patch.

Sorry for flood, if you are working on that issue.

-- 
regards,
Andrey Lepikhov
Postgres Professional





view thread (46+ messages)  latest in thread

Message-ID: <0b819232-4b50-f245-1c7d-c8c61bf41827@postgrespro.ru>
Permalink:  ../0b819232-4b50-f245-1c7d-c8c61bf41827@postgrespro.ru/
Also on:    postgresql.org/message-id/0b819232-4b50-f245-1c7d-c8c61bf41827@postgrespro.ru

 · 

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-bugs@postgresql.org
  Cc: a.lepikhov@postgrespro.ru, pgsql-bugs@lists.postgresql.org
  Subject: Re: Clause accidentally pushed down ( Possible bug in Making Vars outer-join aware)
  In-Reply-To: <0b819232-4b50-f245-1c7d-c8c61bf41827@postgrespro.ru>

* 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