pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Masahiko Sawada <msawada@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Refactor COPY FROM to use format callback functions.
Date: Fri, 28 Feb 2025 18:31:12 +0000
Message-ID: <E1to58i-000AeZ-03@gemulon.postgresql.org> (raw)

Refactor COPY FROM to use format callback functions.

This commit introduces a new CopyFromRoutine struct, which is a set of
callback routines to read tuples in a specific format. It also makes
COPY FROM with the existing formats (text, CSV, and binary) utilize
these format callbacks.

This change is a preliminary step towards making the COPY FROM command
extensible in terms of input formats.

Similar to 2e4127b6d2d, this refactoring contributes to a performance
improvement by reducing the number of "if" branches that need to be
checked on a per-row basis when sending field representations in text
or CSV mode. The performance benchmark results showed ~5% performance
gain in text or CSV mode.

Author: Sutou Kouhei <kou@clear-code.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Tomas Vondra <tomas.vondra@enterprisedb.com>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Discussion: https://postgr.es/m/20231204.153548.2126325458835528809.kou@clear-code.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7717f63006935de00fafd000bff450280508adf1

Modified Files
--------------
src/backend/commands/copyfrom.c          | 192 ++++++++++---
src/backend/commands/copyfromparse.c     | 446 +++++++++++++++++--------------
src/include/commands/copy.h              |   2 -
src/include/commands/copyapi.h           |  50 +++-
src/include/commands/copyfrom_internal.h |  11 +
src/tools/pgindent/typedefs.list         |   1 +
6 files changed, 459 insertions(+), 243 deletions(-)



view thread (9+ messages)  latest in thread

Message-ID: <E1to58i-000AeZ-03@gemulon.postgresql.org>
Permalink:  ../E1to58i-000AeZ-03@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1to58i-000AeZ-03@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: msawada@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Refactor COPY FROM to use format callback functions.
  In-Reply-To: <E1to58i-000AeZ-03@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox