Regards, Zhang Mingli On Sep 19, 2022, 23:14 +0800, Tom Lane <t...@sss.pgh.pa.us>, wrote: > Very little of the planner bothers with freeing small allocations > like that. I think so too, as said, not sure if it worths. > Can you demonstrate a case where this would actually > make a meaningful difference? Offhand, an example may help a little:
create table t1(id int); explain select max(id), min(id), sum(id), count(id), avg(id) from t1; Modify codes to test: @@ -139,6 +139,7 @@ preprocess_aggref(Aggref *aggref, PlannerInfo *root) int16 transtypeLen; Oid inputTypes[FUNC_MAX_ARGS]; int numArguments; + static size_t accumulate_list_size = 0; Assert(aggref->agglevelsup == 0); @@ -265,7 +266,7 @@ preprocess_aggref(Aggref *aggref, PlannerInfo *root) aggserialfn, aggdeserialfn, initValue, initValueIsNull, same_input_transnos); - list_free(same_input_transnos); + accumulate_list_size += sizeof(int) * list_length(same_input_transnos); Gdb and print accumulate_list_size for each iteration: SaveBytes = Sum results of accumulate_list_size: 32(4+4+8+8), as we have 5 aggs in sql. If there were N sets of that aggs (more columns as id, with above aggs ), the bytes will be N*SaveBytes. Seems we don’t have so many agg functions that could share the same trans function, Does it worth?