PostgreSQL Bulk Loading: COPY, Unlogged Staging, and Deferred Indexes
Loading millions of rows with single-row INSERTs is the slowest possible choice. COPY, batching, building indexes after the load, and managing WAL turn an overnight job into a coffee break.