public inbox for [email protected]
help / color / mirror / Atom feedFrom: Michael Paquier <[email protected]>
To: Tom Lane <[email protected]>
Cc: Shinya Kato <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: Add LIMIT option to COPY FROM
Date: Wed, 4 Feb 2026 15:21:29 +0900
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <CAOzEurR2N3iEG6fgQ34EjDghQEv-3u7t69dMw6KqOTq12J3zNg@mail.gmail.com>
<[email protected]>
On Tue, Feb 03, 2026 at 09:41:54AM -0500, Tom Lane wrote:
> Do we really need this? Each random feature we load onto COPY
> slows it down for everybody.
[ ...reads the patch... ]
@@ -1122,6 +1122,32 @@ CopyFrom(CopyFromState cstate)
*/
ResetPerTupleExprContext(estate);
+ /*
+ * Stop early when LIMIT would be exceeded. In multi-insert mode,
+ * include already buffered tuples so we don't overshoot.
+ */
+ if (cstate->opts.limit > 0)
This is an extra check in the per-row processing of COPY FROM, that
can never be skipped as the limit needs to be checked all the time,
once per row. This is not going to be entirely free, more noticeable
when processing many rows with few attributes.
--
Michael
Attachments:
[application/pgp-signature] signature.asc (833B, ../[email protected]/2-signature.asc)
download
view thread (2+ messages)
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: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: Add LIMIT option to COPY FROM
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox