Re: BUG #17618: unnecessary filter column <> text even after adding index - Mailing list pgsql-bugs

From Richard Guo
Subject Re: BUG #17618: unnecessary filter column <> text even after adding index
Date
Msg-id CAMbWs48DuHbqtAgMjpj5Jq_ubxR0+SS-urLuVi=9Dx5FTkJieA@mail.gmail.com
Whole thread Raw
In response to Re: BUG #17618: unnecessary filter column <> text even after adding index  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #17618: unnecessary filter column <> text even after adding index
List pgsql-bugs

On Sun, Nov 6, 2022 at 1:07 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Richard Guo <guofenglinux@gmail.com> writes:
> Update with v3 patch, nothing changes except fixes a test failure
> spotted by cfbot.

I think this is pretty close to usable, except that I don't believe
reusing simplify_boolean_equality this way is a great idea.
It does more than we need (surely the LHS-is-Const case cannot occur here)
and it has assumptions that I'm not sure hold --- particularly the bit
about !constisnull.  I'd be inclined to just copy-and-paste the three or
four lines we need.
 
Thanks for the suggestion.  Yes, simplify_boolean_equality is doing more
than we need.  I think here we just intend to handle indexquals of form
"indexkey = true/false", which seems can only come out from function
match_boolean_index_clause.  From what this function does, we are sure
the constant input can be only on right (as you pointed out), and the
operator can only be BooleanEqualOperator.  Also it seems the assumption
about !constisnull holds, as match_boolean_index_clause would not make a
clause with a constant-NULL input.

I've updated the patch according to the suggestions as in v4.  Thanks
for reviewing this patch!

Thanks
Richard
Attachment

pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #17680: execute alter composite type and select composite type concurrently, may cause pg coredump
Next
From: Tom Lane
Date:
Subject: Re: BUG #17679: REFRESH MATERIALIZED VIEW CONCURRENTLY leaves temporary files?