Re: Free list same_input_transnos in preprocess_aggref - Mailing list pgsql-hackers

From Zhang Mingli
Subject Re: Free list same_input_transnos in preprocess_aggref
Date
Msg-id 7586c7bf-9dd1-4f7a-98e2-455cb03d6316@Spark
Whole thread Raw
In response to Re: Free list same_input_transnos in preprocess_aggref  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Free list same_input_transnos in preprocess_aggref
List pgsql-hackers

Regards,
Zhang Mingli
On Sep 19, 2022, 23:14 +0800, Tom Lane <tgl@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?




pgsql-hackers by date:

Previous
From: Himanshu Upadhyaya
Date:
Subject: Re: HOT chain validation in verify_heapam()
Next
From: Jacob Champion
Date:
Subject: Re: Support tls-exporter as channel binding for TLSv1.3