| From: | Andrei Lepikhov <lepihov(at)gmail(dot)com> |
|---|---|
| To: | Josh Hurst <joshhurst77(at)gmail(dot)com> |
| Cc: | geidav(dot)pg(at)gmail(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-11-29 09:56:23 |
| Message-ID: | 506b831c-b0be-4f1e-a6ea-1bb537a696ef@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 28/11/2026 21:49, Josh Hurst wrote:
> First I'll benchmark your arithmetic series against mine. I mostly want
> to know whether my uint64 multiply path for products of up to 4 digits
> gains enough to be worth keeping, or whether your simpler loop does
> just as well. After that I'll start a new thread for the fast short
> arithmetic and credit you there. The aggregate and HashAgg memory work
> can get its own thread later.
Feel free to merge the best ideas and continue.
The reason why I supported 5 digits is that ERPs' decimal calculations are specific:
According to financial law, they usually have to support up to numeric(38,0)
[1]. But by analysing actual schemas, I found that most numbers stored in fields
are up to numeric(18,2) and numeric(20,4). 4 digits maximum numeric(16,4) covers
only ~30-40% of typical numeric fields in the schema.
Just to be clear, let me explain why all that activity started.
Current Postgres aggregate machinery works well when you have a human-readable
number of groups. ERPs' usual template is the following:
INSERT INTO ... SELECT DISTINCT .. FROM ...
So, they typically extract data from tables, perform operations and store the
result to other (or the same) tables. The number of resulting groups is huge and
typically close to the number of input rows. Each group needs memory
allocations/deallocations, and these optimisations significantly reduce memory
operations and consumption in such cases.
--
regards, Andrei Lepikhov,
pgEdge
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jelte Fennema-Nio | 2026-11-29 10:55:23 | Re: Safer and simpler HTAB macros (foreach_hash and hash_make), take two |
| Previous Message | Manu | 2026-11-29 05:25:23 | Reject columns of permanent relations that depend on temporary objects |