Re: Use virtual tuple slot for Unique node

2023-08-31 Thread Денис Смирнов
Again the new patch hasn't been attached to the thread, so resend it.


v3-use-virtual-slots-for-unique-node.patch
Description: Binary data


Use virtual tuple slot for Unique node

2023-08-30 Thread Денис Смирнов
Hi,

I have inspected the performance of the GROUP BY and DISTINCT queries for the 
sorted data streams and found out, that Group node (produced by GROUP BY) works 
faster then the Unique node (produced by DISTINCT).  The flame graph should out 
the reason - Unique palloc`s tuples for the result slot while the Group node 
doesn’t.

I wonder, why do we use minimal tuples for the Unique node instead of the 
virtual ones? It looks like there is no actual reason for that as Unique 
doesn’t make any materialization.
diff --git a/src/backend/executor/nodeUnique.c 
b/src/backend/executor/nodeUnique.c
index 45035d74fa..c859add6e0 100644
--- a/src/backend/executor/nodeUnique.c
+++ b/src/backend/executor/nodeUnique.c
@@ -141,7 +141,7 @@ ExecInitUnique(Unique *node, EState *estate, int eflags)
 * Initialize result slot and type. Unique nodes do no projections, so
 * initialize projection info for this node appropriately.
 */
-   ExecInitResultTupleSlotTL(>ps, );
+   ExecInitResultTupleSlotTL(>ps, );
uniquestate->ps.ps_ProjInfo = NULL;
 
/*