cache type info in json_agg and friends - Mailing list pgsql-hackers

From Andrew Dunstan
Subject cache type info in json_agg and friends
Date
Msg-id 55F71E7B.5020104@dunslane.net
Whole thread Raw
Responses Re: cache type info in json_agg and friends  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Re: cache type info in json_agg and friends  (Teodor Sigaev <teodor@sigaev.ru>)
List pgsql-hackers
Currently, json_agg, jsonb_agg, json_object_agg and jsonb_object_agg do
type classification on their arguments on each call to the transition
function. This is quite unnecessary, as the argument types won't change.
This patch remedies the defect by caching the necessary values in the
aggregate state object.

While this doesn't change the performance much, since these functions
are essentially dominated by other bits of the processing, I think it is
nevertheless worth doing.

There are other areas where we might attack this, also. In particular,
if one of the arguments is a record, then composite_to_json(b) will do
this for every attribute of every record. However, it's much less clear
to me how we can cache this information sensibly.

cheers

andrew

Attachment

pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: jsonb_set array append hack?
Next
From: Alvaro Herrera
Date:
Subject: Re: cache type info in json_agg and friends