Pick the fix
A nightly job inserts 2 million rows with one autocommitted INSERT each. Best change?
Hint 1 of 1
What does each autocommit do?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A Load with COPY in batches inside transactions
Correct. Removes per-row round trips and commits.
Each autocommitted INSERT pays a round trip, a parse and a WAL flush. COPY streams many rows in one command, and committing in large batches turns 2 million flushes into a few hundred.
Why not the others?
- B Add an index on every column. Slows inserts further.
- C Run the job twice as often. Same total cost.
- D Raise the connection pool size. The cost is per row, not connection count.