mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
In array_agg(), don't create a new context for every group.
Previously, each new array created a new memory context that started out at 8kB. This is incredibly wasteful when there are lots of small groups of just a few elements each. Change initArrayResult() and friends to accept a "subcontext" argument to indicate whether the caller wants the ArrayBuildState allocated in a new subcontext or not. If not, it can no longer be released separately from the rest of the memory context. Fixes bug report by Frank van Vugt on 2013-10-19. Tomas Vondra. Reviewed by Ali Akbar, Tom Lane, and me.
This commit is contained in:
@@ -1218,7 +1218,7 @@ plperl_array_to_datum(SV *src, Oid typid, int32 typmod)
|
||||
errmsg("cannot convert Perl array to non-array type %s",
|
||||
format_type_be(typid))));
|
||||
|
||||
astate = initArrayResult(elemtypid, CurrentMemoryContext);
|
||||
astate = initArrayResult(elemtypid, CurrentMemoryContext, true);
|
||||
|
||||
_sv_to_datum_finfo(elemtypid, &finfo, &typioparam);
|
||||
|
||||
|
Reference in New Issue
Block a user