Re: Make COPY format extendable: Extract COPY TO format implementations

From: Sutou Kouhei <kou(at)clear-code(dot)com>
To: sawada(dot)mshk(at)gmail(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Make COPY format extendable: Extract COPY TO format implementations
Date: 2024-09-28 15:56:45
Message-ID: 20240929.005645.1104697064625237361.kou@clear-code.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

In <CAD21AoCwMmwLJ8PQLnZu0MbB4gDJiMvWrHREQD4xRp3-F2RU2Q(at)mail(dot)gmail(dot)com>
"Re: Make COPY format extendable: Extract COPY TO format implementations" on Fri, 27 Sep 2024 16:33:13 -0700,
Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:

>> * 0005 (that add "void *opaque" to Copy{From,To}StateData)
>> has a bit negative impact for FROM and a bit positive
>> impact for TO
>> * But I don't know why. This doesn't change per row
>> related codes. Increasing Copy{From,To}StateData size
>> ("void *opaque" is added) may be related.
>
> I was surprised that the 0005 patch made COPY FROM slower (with fewer
> rows) and COPY TO faster overall in spite of just adding one struct
> field and some functions.

Me too...

> I'm interested in why the performance trends of COPY FROM are
> different between fewer than 6M rows and more than 6M rows.

My hypothesis:

With this patch set:
1. One row processing is faster than master.
2. Non row related processing is slower than master.

If we have many rows, 1. impact is greater than 2. impact.

> Separating the patches into two parts (one is for COPY TO and another
> one is for COPY FROM) could be a good idea. It would help reviews and
> investigate performance regression in COPY FROM cases. And I think we
> can commit them separately.
>
> Also, could you please rebase the patches as they conflict with the
> current HEAD?

OK. I've prepared 2 patch sets:

v20: It just rebased on master. It still mixes COPY TO and
COPY FROM implementations.

v21: It's based on v20 but splits COPY TO implementations
and COPY FROM implementations.
0001-0005 includes only COPY TO related changes.
0006-0010 includes only COPY FROM related changes.

(v21 0001 + 0006) == (v20 v0001),
(v21 0002 + 0007) == (v20 v0002) and so on.

> I'll run some benchmarks on my environment as well.

Thanks. It's very helpful.

Thanks,
--
kou

Attachment Content-Type Size
v20-0001-Add-CopyToRoutine-CopyFromRountine.patch text/x-patch 10.4 KB
v20-0002-Use-CopyToRoutine-CopyFromRountine-for-the-exist.patch text/x-patch 43.3 KB
v20-0003-Add-support-for-adding-custom-COPY-TO-FROM-forma.patch text/x-patch 20.2 KB
v20-0004-Export-CopyToStateData-and-CopyFromStateData.patch text/x-patch 31.1 KB
v20-0005-Add-support-for-implementing-custom-COPY-TO-FROM.patch text/x-patch 3.4 KB
v21-0001-Add-CopyToRountine.patch text/x-patch 5.6 KB
v21-0002-Use-CopyToRountine-for-the-existing-formats.patch text/x-patch 14.1 KB
v21-0003-Add-support-for-adding-custom-COPY-TO-format.patch text/x-patch 17.6 KB
v21-0004-Export-CopyToStateData.patch text/x-patch 14.8 KB
v21-0005-Add-support-for-implementing-custom-COPY-TO-form.patch text/x-patch 1.8 KB
v21-0006-Add-CopyFromRoutine.patch text/x-patch 6.5 KB
v21-0007-Use-CopyFromRoutine-for-the-existing-formats.patch text/x-patch 30.2 KB
v21-0008-Add-support-for-adding-custom-COPY-FROM-format.patch text/x-patch 8.9 KB
v21-0009-Export-CopyFromStateData.patch text/x-patch 17.6 KB
v21-0010-Add-support-for-implementing-custom-COPY-FROM-fo.patch text/x-patch 2.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2024-09-28 17:26:21 Re: msys inet_pton strangeness
Previous Message Tom Lane 2024-09-28 15:49:06 Re: msys inet_pton strangeness