pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: Евгений Плискин <eugene.pliskin@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Suggest using boolean index with (bflag is true) condition for the query with (bflag = true) clause
Date: Mon, 19 Sep 2022 10:33:42 -0400
Message-ID: <337633.1663598022@sss.pgh.pa.us> (raw)
In-Reply-To: <dcceae342f9ee16e84acf2f215dec73d0757b6a2.camel@cybertec.at>
References: <519561082.20220918182435@gmail.com>
	<dcceae342f9ee16e84acf2f215dec73d0757b6a2.camel@cybertec.at>

Laurenz Albe <laurenz.albe@cybertec.at> writes:
> On Sun, 2022-09-18 at 18:24 +0300, Евгений Плискин wrote:
>> So why not use this index for this query?

> Because the conditions are different:

> SELECT NULL = TRUE, NULL IS TRUE;
>  ?column? │ ?column? 
> ══════════╪══════════
>           │ f
> (1 row)

> The first result is NULL.

Nonetheless, indxpath.c knows it can transform between "bool = true"
and "bool IS TRUE" for the purpose of making an index search
qualification, so it seems a bit odd that we fail to do the equivalent
transformation when attempting to prove an index predicate.

It'd be possible to improve this by adding some proof rules to
predicate_implied_by_simple_clause: I think both "x => x IS TRUE"
and the converse would be valid per the proof requirements, and
if you wanted to gild the lily it'd likely be possible to handle
some related cases like "x => x IS NOT FALSE".

Whether it's worth the cycles isn't too clear to me, but we could
argue about that if somebody submitted a patch.

			regards, tom lane





view thread (3+ messages)

Message-ID: <337633.1663598022@sss.pgh.pa.us>
Permalink:  ../337633.1663598022@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/337633.1663598022@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-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, laurenz.albe@cybertec.at, eugene.pliskin@gmail.com
  Subject: Re: Suggest using boolean index with (bflag is true) condition for the query with (bflag = true) clause
  In-Reply-To: <337633.1663598022@sss.pgh.pa.us>
  References: <519561082.20220918182435@gmail.com> <dcceae342f9ee16e84acf2f215dec73d0757b6a2.camel@cybertec.at> <337633.1663598022@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