| From: | shihao zhong <zhong950419(at)gmail(dot)com> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: [PG19] jsonb_object_agg as a window function returns stale values |
| Date: | 2026-10-14 04:02:30 |
| Message-ID: | CAGRkXqQ4v2-zN9m5ttn3pf3DJ4eGMWLSua61p=voYE8O1fFHxA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Tom,
> One alternative could be to use the extra palloc/memcpy only when
> skip_nulls is true, after fixing uniqueifyJsonbObject to renumber
> the pairs.
v2 does that, with a narrower test for the copy. Removing null pairs
from the state is harmless unless unique_keys is also set, since the
dedup loop skips nulls before it looks for duplicates. So 0001 copies
the pairs only for jsonb_object_agg_unique_strict.
With your benchmark on a non-assert build, HEAD and v2 both take about
10 ms of backend CPU, and v1 takes 5.6 s :( .
> (Independently of all this, the documentation for the json-object
> aggregates is seriously awful.
0003 is a try at that. It says which value wins for a repeated key,
and that null values are dropped first but still count in the unique
check.
Thanks,
Shihao
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0002-Add-tests-for-jsonb_object_agg-as-a-window-functi.patch | application/octet-stream | 3.0 KB |
| v2-0003-Document-duplicate-key-handling-of-the-JSON-objec.patch | application/octet-stream | 2.2 KB |
| v2-0001-Fix-jsonb_object_agg-used-as-a-window-function.patch | application/octet-stream | 3.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | shihao zhong | 2026-10-14 04:07:15 | Re: [PG19] Stale state after the join removal restart gives wrong results |
| Previous Message | Bharath Rupireddy | 2026-10-14 04:00:00 | Re: Parallel autovacuum: DROP DATABASE WITH (FORCE) fails on the parallel workers |