Re: Does TupleQueueReaderNext() really need to copy its result? - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: Does TupleQueueReaderNext() really need to copy its result?
Date
Msg-id CA+hUKGJLt=s0NQA7_4X_sAgLXURiZ7TGkpaFWBpM0==-2q6a4g@mail.gmail.com
Whole thread Raw
In response to Re: Does TupleQueueReaderNext() really need to copy its result?  (Soumyadeep Chakraborty <soumyadeep2007@gmail.com>)
Responses Re: Does TupleQueueReaderNext() really need to copy its result?  (Soumyadeep Chakraborty <soumyadeep2007@gmail.com>)
List pgsql-hackers
On Sat, Jul 11, 2020 at 1:37 PM Soumyadeep Chakraborty
<soumyadeep2007@gmail.com> wrote:
> +1 to the idea! I ran some experiments on both of your patches.

Hi Soumyadeep,

Thanks for testing!

> I could reproduce the speed gain that you saw for a plan with a simple
> parallel sequential scan. However, I got no gain at all for a parallel
> hash join and parallel agg query.

Right, it's not going to make a difference when you only send one
tuple through the queue, like COUNT(*) does.

> As for gather merge, is it possible to have a situation where the slot
> input to tqueueReceiveSlot() is a heap slot (as would be the case for a
> simple select *)? If yes, in those scenarios, we would be incurring an
> extra call to minimal_tuple_from_heap_tuple() because of the extra call
> to ExecFetchSlotMinimalTuple() inside tqueueReceiveSlot() in your patch.
> And since, in a gather merge, we can't avoid the copy on the leader side
> (heap_copy_minimal_tuple() inside gm_readnext_tuple()), we would be
> doing extra work in that scenario. I couldn't come up with a plan that
> creates a scenario like this however.

Hmm.  I wish we had a way to do an "in-place" copy-to-minimal-tuple
where the caller supplies the memory, with some fast protocol to get
the size right.  We could use that for copying tuples into shm queues,
hash join tables etc without an extra palloc()/pfree() and double
copy.



pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Default setting for enable_hashagg_disk
Next
From: Thomas Munro
Date:
Subject: Re: Stale external URL in doc?