← All notes

Fast bulk loading in PostgreSQL with COPY

Short answer

Use COPY instead of many INSERTs. It moves data between a table and a file (or STDIN/STDOUT) in one command and has far less overhead. For a new table: create it, COPY the data, then build indexes. [S1][S2]

COPY items (id, name) FROM STDIN WITH (FORMAT csv, HEADER true);

Tips

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: PostgreSQL Global Development Group, PostgreSQL: Documentation: 18: COPY, PostgreSQL License; PostgreSQL Global Development Group, PostgreSQL: Documentation: 18: 14.4. Populating a Database, PostgreSQL License.

Cite this

Permanent ID: iil:note:x9x8akrr

iinventedlight. 2026. "Fast bulk loading in PostgreSQL with COPY." iinventedlight Library, iil:note:x9x8akrr, version of 2026-11-04. https://iinventedlight.com/library/notes/postgres-copy-bulk-load/. License: CC-BY-4.0.

@misc{iil_note_x9x8akrr,
  author = {{iinventedlight}},
  title = {{Fast bulk loading in PostgreSQL with COPY}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-04},
  url = {https://iinventedlight.com/library/notes/postgres-copy-bulk-load/},
  note = {Permanent ID iil:note:x9x8akrr. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/postgres-copy-bulk-load.md.