Re: speedup COPY TO for partitioned table.

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>
Cc: Kirill Reshke <reshkekirill(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: speedup COPY TO for partitioned table.
Date: 2025-06-27 07:14:38
Message-ID: CACJufxGAXrABSJNfDbTgnzWP2g7sYKWYHiqLyc+grAE4sTE+tA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jun 26, 2025 at 9:43 AM torikoshia <torikoshia(at)oss(dot)nttdata(dot)com> wrote:
>
> After applying the patch, blank lines exist between these statements as
> below. Do we really need these blank lines?
>
> ```
> scan_rel = table_open(scan_oid,
> AccessShareLock);
>
> CopyThisRelTo(cstate, scan_rel, cstate->rel,
> &processed);
>
> table_close(scan_rel, AccessShareLock);
> ``
>
we can remove these empty new lines.
actually, I realized we don't need to use AccessShareLock here—we can use NoLock
instead, since BeginCopyTo has already acquired AccessShareLock via
find_all_inheritors.

> > +/*
> > + * rel: the relation from which the actual data will be copied.
> > + * root_rel: if not NULL, it indicates that we are copying partitioned
> > relation
> > + * data to the destination, and "rel" is the partition of "root_rel".
> > + * processed: number of tuples processed.
> > +*/
> > +static void
> > +CopyThisRelTo(CopyToState cstate, Relation rel, Relation root_rel,
>
> This comment only describes the parameters. Wouldn't it better to add a
> brief summary of what this function does overall?
>

what do you think the following

/*
* CopyThisRelTo:
* This will scanning a single table (which may be a partition) and exporting
* its rows to a COPY destination.
*
* rel: the relation from which the actual data will be copied.
* root_rel: if not NULL, it indicates that we are copying partitioned relation
* data to the destination, and "rel" is the partition of "root_rel".
* processed: number of tuples processed.
*/
static void
CopyThisRelTo(CopyToState cstate, Relation rel, Relation root_rel,
uint64 *processed)

Attachment Content-Type Size
v12-0001-support-COPY-partitioned_table-TO.patch text/x-patch 11.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Yugo Nagata 2025-06-27 07:19:59 Re: JIT works only partially with meson build?
Previous Message Andrei Lepikhov 2025-06-27 06:46:29 Re: Removing unneeded self joins