Re: Bug in row_number() optimization - Mailing list pgsql-hackers

From Sergey Shinderuk
Subject Re: Bug in row_number() optimization
Date
Msg-id e126be3a-09ed-7495-778c-1f429f67cb93@postgrespro.ru
Whole thread Raw
In response to Re: Bug in row_number() optimization  (Richard Guo <guofenglinux@gmail.com>)
Responses Re: Bug in row_number() optimization
List pgsql-hackers
On 24.11.2022 06:16, Richard Guo wrote:
> Regarding how to fix this problem, firstly I believe we need to evaluate
> window functions in the per-tuple memory context, as the HEAD does.
> When we decide we need to go into pass-through mode, I'm thinking that
> we can just copy out the results of the last evaluation to the per-query
> memory context, while still storing their pointers in ecxt_aggvalues.
> 
> Does this idea work?
Although I'm not familiar with the code, this makes sense to me.

You proposed:

+#ifdef USE_FLOAT8_BYVAL
+       evalWfuncContext = 
winstate->ss.ps.ps_ExprContext->ecxt_per_tuple_memory;
+#else
+       evalWfuncContext = 
winstate->ss.ps.ps_ExprContext->ecxt_per_query_memory;
+#endif

Shouldn't we handle any pass-by-reference type the same? I suppose, a 
user-defined window function can return some other type, not int8.

Best regards,

-- 
Sergey Shinderuk        https://postgrespro.com/




pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Report roles in pg_upgrade pg_ prefix check
Next
From: Ilya Gladyshev
Date:
Subject: Re: postgres_fdw binary protocol support