Cache argument type information in json(b) aggregate functions.
authorAndrew Dunstan <[email protected]>
Fri, 18 Sep 2015 18:39:39 +0000 (14:39 -0400)
committerPavan Deolasee <[email protected]>
Tue, 18 Oct 2016 10:03:53 +0000 (15:33 +0530)
commitf85609215c9ce5cc8ed4f88e009d0498ef02231d
treedb084c1e986cdbacf4147be8735bf58070c4e60f
parent18cd2bedc5ae06554a880c08af830a08a95c5861
Cache argument type information in json(b) aggregate functions.

These functions have been looking up type info for every row they
process. Instead of doing that we only look them up the first time
through and stash the information in the aggregate state object.

Affects json_agg, json_object_agg, jsonb_agg and jsonb_object_agg.

There is plenty more work to do in making these more efficient,
especially the jsonb functions, but this is a virtually cost free
improvement that can be done right away.

Backpatch to 9.5 where the jsonb variants were introduced.
src/backend/access/heap/heapam.c
src/backend/utils/adt/json.c
src/backend/utils/adt/jsonb.c