Re: POC, WIP: OR-clause support for indexes

From: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Andrei Lepikhov <lepihov(at)gmail(dot)com>, Alena Rybakina <a(dot)rybakina(at)postgrespro(dot)ru>, Nikolay Shaplov <dhyan(at)nataraj(dot)su>, pgsql-hackers(at)lists(dot)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org, Peter Geoghegan <pg(at)bowt(dot)ie>, Marcos Pegoraro <marcos(at)f10(dot)com(dot)br>, teodor(at)sigaev(dot)ru, Peter Eisentraut <peter(at)eisentraut(dot)org>, Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
Subject: Re: POC, WIP: OR-clause support for indexes
Date: 2024-10-08 14:03:29
Message-ID: CAPpHfdunXXFT=jk+3ojXQWo0wZ1Rk=rpmAp+fjcistCWcH7KqA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Oct 7, 2024 at 5:06 PM jian he <jian(dot)universality(at)gmail(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Anton A. Melnikov 2024-10-08 14:16:55 Re: May be BUG. Periodic burst growth of the checkpoint_req counter on replica.
Previous Message Alexander Korotkov 2024-10-08 14:00:08 Re: POC, WIP: OR-clause support for indexes