| From: | Andrei Lepikhov <lepihov(at)gmail(dot)com> |
|---|---|
| To: | Michael Paquier <michael(at)paquier(dot)xyz> |
| Cc: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Nathan Bossart <nathandbossart(at)gmail(dot)com> |
| Subject: | Re: SUM(int2)/SUM(int4) do not detect overflow of the int8 accumulator |
| Date: | 2026-09-02 08:19:29 |
| Message-ID: | d06b7513-68c8-4f9b-81ba-ab1c316189f9@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 02/09/2026 09:37, Michael Paquier wrote:
> On Wed, Sep 02, 2026 at 08:01:56AM +0200, Andrei Lepikhov wrote:
>> In my mind, we should pay for CPU cycles only in practical cases. So, if this
>> case deserves an overflow check, it should be an assertion that consumes no
>> resources in production.
>
> All the patterns you are showing imply direct function calls, which
> don't really seem worth bothering about. Are any of these overflow
> cases reachable using operators with dedicated casts? I would count
> as OK even cases where the sum functions are used in a custom
> aggregate, say with a SFUNC set to one of the paths you are pointing
> at.
I use direct calls mainly to make regression tests run faster.
The first case arose during benchmarking built-in SUM(int4) with various
parallelising methods [1] (bare research topic) at scale. This may not be a big
issue right now, but as databases get larger, it could become one. I think it's
more likely to happen first in the microcurrency space, where the base unit is a
cent instead of a dollar, especially with very large partitioned tables.
[1] https://www.pgedge.com/blog/do-global-hash-tables-strike-back-in-postgresql
--
regards, Andrei Lepikhov,
pgEdge
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alvaro Herrera | 2026-09-02 08:20:20 | Re: REPACK (ANALYZE) within transaction block segfaults |
| Previous Message | David Geier | 2026-09-02 08:09:54 | Re: Reducing relcache memory usage: deduping index shapes |