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