Re: Does TupleQueueReaderNext() really need to copy its result?

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Does TupleQueueReaderNext() really need to copy its result?
Date: 2020-05-14 10:55:15
Message-ID: CA+hUKGJzJ7iuoiRhqTpYXrd4xy71Bcs_ExhrO7OO-JQ_4k+gLA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Aug 27, 2019 at 6:35 AM Andres Freund <andres(at)anarazel(dot)de> wrote:
> On 2019-08-26 14:09:45 -0400, Robert Haas wrote:
> > There's a comment in htup.h which says:
> >
> > * * Separately allocated tuple: t_data points to a palloc'd chunk that
> > * is not adjacent to the HeapTupleData. (This case is deprecated since
> > * it's difficult to tell apart from case #1. It should be used only in
> > * limited contexts where the code knows that case #1 will never apply.)
> >
> > I got scared and ran away.
>
> Perhaps this'd could be sidestepped by funneling through MinimalTuples
> instead of HeapTuples. Afaict that should always be sufficient, because
> all system column accesses ought to happen below (including being
> projected into a separate column, if needed above). With the added
> benefit of needing less space, of course.

I tried that out (attached). That makes various simple tests like
this to go 10%+ faster on my development machine:

create table s as select generate_series(1, 50000000)::int i,
'hello world' a,
'this is a message' b,
42 c;
select pg_prewarm('s');
set force_parallel_mode = on;

explain analyze select * from s;

PS It looks like the following load of mq_ring_size might be running
a little hot due to false sharing with the atomic counters:

if (mqh->mqh_consume_pending > mq->mq_ring_size / 4)

Attachment Content-Type Size
0001-Use-MinimalTuple-for-tuple-queues.patch text/x-patch 10.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2020-05-14 10:58:01 Re: Incorrect OpenSSL type reference in code comment
Previous Message Alexander Korotkov 2020-05-14 10:34:29 Re: pgsql: Show opclass and opfamily related information in psql