Re: Use local buffer for packed numerics

From: Andrei Lepikhov <lepihov(at)gmail(dot)com>
To: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
Cc: David Geier <geidav(dot)pg(at)gmail(dot)com>, Josh Hurst <joshhurst77(at)gmail(dot)com>, chenhuimo(dot)mch(at)qq(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org, "andreas(at)proxel(dot)se" <andreas(at)proxel(dot)se>
Subject: Re: Use local buffer for packed numerics
Date: 2026-12-04 09:13:17
Message-ID: 0b5212ac-9a83-43e3-b421-46608151ba4c@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 03/12/2026 15:43, Matthias van de Meent wrote:
> On Thu, 3 Dec 2026 at 14:08, Andrei Lepikhov <lepihov(at)gmail(dot)com> wrote:
>>
>> On 03/12/2026 13:20, David Geier wrote:
>>> A targeted benchmark tells us whether an optimization helps its
>>> intended workload. It does not tell us what it costs elsewhere.
>>
>> I definitely disagree here. A targeted benchmark must expose all theoretically
>> possible regressions.
>
> Producing a set of benchmarks that shows all theoretically possible
> regressions might mean you'd first have to solve the halting problem,
> because IIUC there are arbitrarily many things that could regress from
> such a base component's code changes. E.g. increasing code size will
> increase instruction cache usage by numeric-related code, which will
> decrease the amount of other system's code in caches, and this will
> affect any number of mixed workloads in various ways. That impact is
> further influenced by the CPU's architecture, memory latencies, etc.

Rereading my previous email, I should confess it wasn't accurate. I am not an
experienced English speaker and make mistakes (frequently). When I tried using
AI translation, people immediately started complaining about AI slop ;).

The code additions obviously change low-level cache behaviour. There is an
infinite field of possibilities. No questions to anyone who wants to spend time
inventing queries. My point is not to hide the fruit: each of these techniques
might be used in multiple places, not just by numeric type. I basically think
about ICU text fields and how costly their comparison is ==> sorting, hashing, etc.

To get to the essence of these patches: There is quite a clear source of
regressions - when the operator passes through each one of the checks and goes
to the fallback path at the last one. So, to show the patch's potential
regression, you just need to construct this case and test it as a part of
different expressions. That's quite simple, I think.
About the positive effect - it depends on the specific use case. In my case,
ERPs always use typmod-ed numerics, typically at the same scale, with zero
fallback calls, and the benchmark that covers these cases shows much better
numbers than we discuss here. I wonder if other engineer will have their own
typical use cases and speedup numbers.

--
regards, Andrei Lepikhov,
pgEdge

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message John Naylor 2026-12-04 09:20:35 Re: Improving scalability of Parallel Bitmap Heap/Index Scan
Previous Message Daniel Gustafsson 2026-12-04 09:12:45 Re: add --transfer-mode to pg_upgrade