| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | nbtree: Cache operator family OID in _bt_setup_array_cmp |
| Date: | 2025-12-31 08:15:49 |
| Message-ID: | CAEoWx2kkCno19Kz1P9L1meuFQYxYg7HctCPc+ySGFDOAbfTCDg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Hackers,
While reviewing a separate patch related to nbtree, I noticed
that _bt_setup_array_cmp in nbtpreprocesskeys.c performs multiple redundant
lookups of the operator family OID via rel->rd_opfamily[skey->sk_attno - 1].
The attached patch caches this value in a local opfamily variable. This
matches the pattern used in several other functions within the same file
(such as _bt_skiparray_strat_decrement, _bt_preprocess_array_keys, etc.),
making the code more consistent and readable.
The assignment is placed after the early-return check for (elemtype ==
opcintype) to ensure we only perform the array indexing when the cross-type
comparison logic is actually reached.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-nbtree-Cache-operator-family-OID-in-_bt_setup_arr.patch | application/octet-stream | 2.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bertrand Drouvot | 2025-12-31 08:42:48 | Re: Don't cast away const where possible |
| Previous Message | jian he | 2025-12-31 08:13:47 | Re: Error position support for ComputeIndexAttrs |