WHERE column = X AND column = Y will always be zero matching rows

Поиск
Список
Период
Сортировка
От [Quipsy] Markus Karg
Тема WHERE column = X AND column = Y will always be zero matching rows
Дата
Msg-id 1e15568107854a75ae8dd35a5a75daa7@quipsy.de
обсуждение исходный текст
Ответы Re: WHERE column = X AND column = Y will always be zero matching rows  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: WHERE column = X AND column = Y will always be zero matching rows  (Laurenz Albe <laurenz.albe@cybertec.at>)
Re: WHERE column = X AND column = Y will always be zero matching rows  (Jaime Casanova <jcasanov@systemguards.com.ec>)
Re: WHERE column = X AND column = Y will always be zero matching rows  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs

Hello PostgreSQL Developers,

 

I am using PostgreSQL 15.3 (Debian 15.3-1.pgdg120+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit.

 

(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!

 

I wonder why squandering any resources into a Scan here, as it is pretty obvious that the result is guaranteed to be always, under any conditions, and will always be: zero matching rows – at least in a universe where a single value cannot be X AND Y at the same time.

 

This can be seen as a chance to add an optimization („col = X AND col = Y always is zero matching rows), or in case such an optimization already exists in PostgreSQL, as a bug.  

 

BTW the same happens for column IS NULL AND column = Y.

 

Regards,

-Markus

 

В списке pgsql-bugs по дате отправления:

Предыдущее
От: David Rowley
Дата:
Сообщение: Re: BUG #18048: Database process terminated automatically
Следующее
От: Justin Tocci
Дата:
Сообщение: Re: BUG #18047: ODBC to PG long transaction causes PANIC