Re: BUG #17618: unnecessary filter column <> text even after adding index
Richard Guo <guofenglinux@gmail.com>
From: Richard Guo <guofenglinux@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Jeff Janes <jeff.janes@gmail.com>, sindysenorita@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2022-11-07T09:01:19Z
Lists: pgsql-bugs
Attachments
- v4-0001-constant-folding-for-indexquals-in-bitmap-scan.patch (application/octet-stream) patch v4-0001
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
Commits
-
Produce more-optimal plans for bitmap scans on boolean columns.
- 042c9091f0fc 16.0 landed