Re: Optimize WindowAgg's use of tuplestores

Tatsuo Ishii <ishii@postgresql.org>

From: Tatsuo Ishii <ishii@postgresql.org>
To: dgrowleyml@gmail.com
Cc: ashutosh.bapat.oss@gmail.com, dgrowley@gmail.com, pgsql-hackers@lists.postgresql.org
Date: 2024-07-12T05:41:08Z
Lists: pgsql-hackers
> @@ -2684,6 +2726,14 @@ ExecEndWindowAgg(WindowAggState *node)
>  	PlanState  *outerPlan;
>  	int			i;
>  
> +	if (node->buffer != NULL)
> +	{
> +		tuplestore_end(node->buffer);
> +
> +		/* nullify so that release_partition skips the tuplestore_clear() */
> +		node->buffer = NULL;
> +	}
> +
> 
> Is it possible that node->buffer == NULL in ExecEndWindowAgg()?  If
> not, probably making it an Assert() or just removing the if() should
> be fine.

Of course it it possible, for example there's no row in a partition.
Sorry for noise.

Best reagards,
--
Tatsuo Ishii
SRA OSS LLC
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp



Commits

  1. Optimize WindowAgg's use of tuplestores

  2. Speedup WindowAgg code by moving uncommon code out-of-line

  3. Improve memory management and performance of tuplestore.c