Re: general purpose array_sort

From: Junwang Zhao <zhjwpku(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: jian he <jian(dot)universality(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Aleksander Alekseev <aleksander(at)timescale(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Amit Langote <amitlangote09(at)gmail(dot)com>, "andreas(at)proxel(dot)se" <andreas(at)proxel(dot)se>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: general purpose array_sort
Date: 2025-04-01 02:27:24
Message-ID: CAEG8a3+aT4+VwOdTNGh+nsAuA91XOtXmmbisg4GMemCiNk9PSQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Apr 1, 2025 at 1:11 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Junwang Zhao <zhjwpku(at)gmail(dot)com> writes:
> > On Mon, Mar 31, 2025 at 5:58 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2025-04-01 02:33:15 Re: Statistics Import and Export
Previous Message Melanie Plageman 2025-04-01 02:14:07 Re: Using read stream in autoprewarm