From: [Quipsy] Markus Karg <karg@quipsy.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: AW: WHERE column = X AND column = Y will always be zero matching rows
Date: Fri, 4 Aug 2023 06:12:55 +0000
Message-ID: <0e20d207845f41609f91ce499c08c759@quipsy.de> (raw)
In-Reply-To: <3497515.1691085559@sss.pgh.pa.us>
References: <1e15568107854a75ae8dd35a5a75daa7@quipsy.de>
<3497515.1691085559@sss.pgh.pa.us>
Tom,
thanks a lot for your kind explanation, this was very interesting to read!
In fact, I have missed the "never executed" marks.
BTW, I did not "complain". I just noticed something and was unclear if this is a bug or not, and I clearly told so in the opening of my posting. It was definitively not my intention to bother or annoy anybody, actually. Sorry to have troubled so many in this mailing list.
-Markus
-----Ursprüngliche Nachricht-----
Von: Tom Lane <tgl@sss.pgh.pa.us>
Gesendet: Donnerstag, 3. August 2023 19:59
An: [Quipsy] Markus Karg <karg@quipsy.de>
Cc: pgsql-bugs@lists.postgresql.org
Betreff: Re: WHERE column = X AND column = Y will always be zero matching rows
"[Quipsy] Markus Karg" <karg@quipsy.de> writes:
> (In the following X and Y are literals; X <> Y) I noticed is that...
> EXPLAIN SELECT column FROM Table WHERE column = X AND column = Y
> ...says that PostgreSQL actually wants to perform a Scan!
You should learn to read plans before complaining about them.
What you actually get is something like
regression=# explain analyze select * from tenk1 where hundred = 42 and hundred = 99;
QUERY PLAN
-----------------------------------------------------------------------------------------------------
Result (cost=5.04..224.95 rows=1 width=244) (actual time=0.001..0.002 rows=0 loops=1)
One-Time Filter: false
-> Bitmap Heap Scan on tenk1 (cost=5.04..224.95 rows=1 width=244) (never executed)
Recheck Cond: (hundred = 42)
-> Bitmap Index Scan on tenk1_hundred (cost=0.00..5.04 rows=100 width=0) (never executed)
Index Cond: (hundred = 42) Planning Time: 0.148 ms Execution Time: 0.046 ms
(8 rows)
See the "never executed" markings? The one-time filter prevents anything below the Result from actually doing anything.
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: karg@quipsy.de, tgl@sss.pgh.pa.us, pgsql-bugs@lists.postgresql.org
Subject: Re: AW: WHERE column = X AND column = Y will always be zero matching rows
In-Reply-To: <0e20d207845f41609f91ce499c08c759@quipsy.de>
* 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