Re: POC, WIP: OR-clause support for indexes - Mailing list pgsql-hackers

From Alexander Korotkov
Subject Re: POC, WIP: OR-clause support for indexes
Date
Msg-id CAPpHfdunXXFT=jk+3ojXQWo0wZ1Rk=rpmAp+fjcistCWcH7KqA@mail.gmail.com
Whole thread Raw
In response to Re: POC, WIP: OR-clause support for indexes  (jian he <jian.universality@gmail.com>)
List pgsql-hackers
On Mon, Oct 7, 2024 at 5:06 PM jian he <jian.universality@gmail.com> wrote:
> assume v40 is the latest version.
> in group_similar_or_args
> we can add a bool variable so
>
> bool        matched = false;
> foreach(lc, orargs)
> {
>                 if (match_index_to_operand(nonConstExpr, colnum, index))
>                 {
>                     matches[i].indexnum = indexnum;
>                     matches[i].colnum = colnum;
>                     matches[i].opno = opno;
>                     matches[i].inputcollid = clause->inputcollid;
>                     matched = true;
>                     break;
>                 }
> }
> ...
>     if (!matched)
>         return orargs;
>     /* Sort clauses to make similar clauses go together */
>     qsort(matches, n, sizeof(OrArgIndexMatch), or_arg_index_match_cmp);
> ....
>
>
> I guess it can save some cycles?

Do you mean we can quit early if no clause matches no index?  Sounds
reasonable, will do.

One other thing that I noticed is "if (matches[i].indexnum >= 0)"
check is one level inner than it should be.  That will be fixed in the
next revision of patch.

------
Regards,
Alexander Korotkov
Supabase



pgsql-hackers by date:

Previous
From: Alexander Korotkov
Date:
Subject: Re: POC, WIP: OR-clause support for indexes
Next
From: "Anton A. Melnikov"
Date:
Subject: Re: May be BUG. Periodic burst growth of the checkpoint_req counter on replica.