Re: Add LIMIT option to COPY FROM

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: Add LIMIT option to COPY FROM
Дата
Msg-id aYLlaaGexTGyUtLS@paquier.xyz
обсуждение исходный текст
Ответ на Re: Add LIMIT option to COPY FROM  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
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

Вложения

В списке pgsql-hackers по дате отправления: