On Tue, Apr 1, 2025 at 1:11 AM Tom Lane <t...@sss.pgh.pa.us> wrote: > > Junwang Zhao <zhjw...@gmail.com> writes: > > On Mon, Mar 31, 2025 at 5:58 AM Tom Lane <t...@sss.pgh.pa.us> wrote: > >> In v18, it's somewhat annoying that the typcache doesn't cache > >> the typarray field; we would not need a separate get_array_type() > >> lookup if it did. I doubt there is any real reason for that except > >> that pg_type.typarray didn't exist when the typcache was invented. > >> So I'm tempted to add it. But I looked at existing callers of > >> get_array_type() and none of them are adjacent to typcache lookups, > >> so only array_sort would be helped immediately. I left it alone > >> for the moment; wonder if anyone else has an opinion? > > > The need for `elmtyp` and `array_type` here because a column can > > have arrays with varying dimensions. Maybe other callers don't share > > this behavior? > > Maybe. I think some of what's going on here is that because for a > long time we only had pg_type.typelem and not pg_type.typarray, > code was written to not need to look up the array type if at all > possible. So there are simply not that many users. Anyway it > seems really cheap to add this field to the typcache now. > > Attached 0001 is the same as v18, and then 0002 is the proposed > addition to typcache.
I've applied the patches to master and regression passed. 0002 is neat, I am +1 for this improvement. > > regards, tom lane > -- Regards Junwang Zhao