| From: | Florents Tselai <florents(dot)tselai(at)gmail(dot)com> |
|---|---|
| To: | Shinya Kato <shinya11(dot)kato(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Add LIMIT option to COPY FROM |
| Date: | 2026-02-03 15:07:18 |
| Message-ID: | CA+v5N41wVFz4akXPxknCX6utxUwx35EJMu2WCYbaX5yF240LZQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Tue, Feb 3, 2026 at 3:49 PM Shinya Kato <shinya11(dot)kato(at)gmail(dot)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);
>
I work with such scenarios a lot and I can't see why COPY should worry
itself about such filtering.
IRL most of what goes into COPY'S STDIN has already been filtered
extensively,
like ... | head -n 100 | COPY t FROM STDIN
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andres Freund | 2026-02-03 15:14:11 | Re: Remove freelist reference in buf_init.c |
| Previous Message | Aleksander Alekseev | 2026-02-03 14:56:16 | Re: [PATCH] Refactor *_abbrev_convert() functions |