Re: Add LIMIT option to COPY FROM

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Add LIMIT option to COPY FROM
Дата
Msg-id CAKFQuwYmK0AXqW0R_tQW7vvNTkCj3TN3eZi8w1ECJEBdKuqktw@mail.gmail.com
обсуждение исходный текст
Ответ на Add LIMIT option to COPY FROM  (Shinya Kato <shinya11.kato@gmail.com>)
Список pgsql-hackers
On Tuesday, February 3, 2026, Shinya Kato <shinya11.kato@gmail.com> wrote:
Hi hackers,

I'd like to propose adding a LIMIT option to COPY FROM, which limits
the number of rows to load.

With COPY TO, we can use the LIMIT clause in the query to restrict
output rows, but COPY FROM has no equivalent way to limit the number
of rows to load (except using the PROGRAM option with external tools
like head). This patch resolves that asymmetry.

Syntax example:
- COPY t FROM STDIN (LIMIT 100);

This feature is useful for:
- Loading only the first N rows from a huge CSV file to verify data or
table definitions before a full import

Would want it paired with offset for this use case.

Design:
- The LIMIT count applies after WHERE filtering and ON_ERROR skipping,
so it represents the actual number of rows inserted.

Not sure about that choice.  I’d go with pre-eval or implement both and default to pre-eval.

David J.

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