One INSERT per row vs one INSERT per batch
1000 separate INSERT statements take 1000 round trips. One INSERT with 1000 rows takes one round trip. The speedup is typically 50-100×. For really large data loads, COPY is another order of magnitude faster than multi-row INSERT.
The hierarchy of speed
- Single-row INSERT in a loop — slowest, one round trip each.
- Multi-row INSERT — fast, one round trip per batch.
- COPY FROM STDIN — fastest, streams data directly into the table without parsing each row as a separate statement.
- COPY with binary format — fastest of all; bypasses text parsing entirely.
When to use which
Routine application writes: multi-row INSERT (most ORMs do this implicitly). Big imports, ETL, seeding: COPY. Loading a billion rows: COPY in binary format with \copy or pgloader.