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: v2-0002-Add-tests-for-jsonb_object_agg-as-a-window-functi.patch
Description: Binary data

Attachment: v2-0003-Document-duplicate-key-handling-of-the-JSON-objec.patch
Description: Binary data

Attachment: v2-0001-Fix-jsonb_object_agg-used-as-a-window-function.patch
Description: Binary data

Reply via email to