pg_fastload parallelizes PostgreSQL bulk loads without leaving one transaction
pg_fastload 1.0.0 is a parallel bulk loader for PostgreSQL. It is a source-level fork of pg_bulkload 3.1.23, with the same control-file syntax, type values, log format, and writer modes. The headline is a 1.58x speedup over the best upstream pg_bulkload mode and a 6.07x speedup over COPY on a 1 GiB TPC-H lineitem CSV. The more interesting engineering claim is that the load stays inside one transaction while the parsing work is spread across background workers.
That combination is unusual. Many bulk-loading tricks buy speed by relaxing transactional semantics: load into an unlogged table, commit in batches, use a second connection, or stage the data and merge it later. pg_fastload takes a different route. It parallelizes the read, parse, and tuple-formation stages, but the leader still performs the insert serially. The transaction boundary is preserved, and the cost is a hard ceiling on how much the parallel pipeline can help.
The 6x headline needs a footnote
The 6.07x number is a comparison with PostgreSQL's COPY ... FROM, not with pg_bulkload's best mode. The benchmark is a 1 GiB TPC-H lineitem CSV with 7,375,042 rows, run on 16 vCPUs with a warm cache, WRITER=DIRECT, and no indexes. The median of three runs for COPY was 8.32 seconds. The default pg_fastload configuration, with 15 workers, took 1.37 seconds. That is 6.07x faster than COPY and 4.24x faster than pg_fastload's own serial mode.
The comparison with pg_bulkload is more modest. Upstream pg_bulkload's best mode, PARALLEL, took 6.63 seconds in the full matrix. pg_fastload's default took 1.40 seconds in the same matrix, which is about 4.7x faster, and the release notes describe the honest headline as 1.58x over the best upstream mode when comparing the main benchmark rows. The difference between 1.58x and 4.7x depends on which upstream mode and which run you use. The author is explicit about this, which is a good sign. A vendor who publishes the less flattering comparison is usually trying to tell you something true.
The benchmark is also narrow. It uses a warm cache, a single file, no indexes, and a CSV format that is parse-heavy. That is the best case for a parallel parser. A cold cache, a smaller file, a table with many indexes, or a workload dominated by WAL will produce a smaller gain. The author asks for counter-examples on other hardware and larger-than-RAM datasets, which suggests the benchmark is meant as a starting point rather than a universal claim.
How the parallel pipeline works
A bulk load has four stages: read the input, parse each record and split it into fields, form the tuple, and insert the tuple into the table. In a conventional loader, all four stages run in one backend. On a 16-core machine, that leaves 15 cores idle during the parse, which is often the most expensive part. CSV parsing is a byte-at-a-time state machine followed by a type input function for each column.
pg_fastload moves the first three stages to background workers. A single reader scans the input file sequentially and hands chunks to the parser workers over shm_mq, PostgreSQL's shared-memory message queue. The workers never open the file themselves. That matters because it keeps the total read volume at one times the file size. If every worker opened the file and seeked to a different offset, the load could read the same pages multiple times, and the speedup could disappear once the data no longer fits in the page cache.
The parser workers split records, form tuples, and pass them back to the leader. The leader performs the insert serially. That is the part that keeps the load transactional: there is one backend writing to the table, one transaction, and one visibility boundary. A bad row aborts the whole load instead of leaving a worker-timing-dependent subset behind. There is no second connection and no early visibility of uncommitted rows.
The serial path was also optimized. Records without quotes or carriage returns use a memchr bulk split instead of the byte-at-a-time loop. That helps even when the parallel path is disabled, and it explains why pg_fastload's serial mode is faster than upstream pg_bulkload in the benchmark.
The fallback list is the real compatibility contract
The parallel path cannot handle every input mode. pg_fastload lists 13 conditions that force an automatic fallback to the serial path, with one INFO line explaining why. The list includes FILTER, FORCE_NOT_NULL, explicit ENCODING, NOT NULL or CHECK constraints, PARSE_ERRORS tolerance, STDIN input, TUPLE and FUNCTION input, and several others.
That list is more important than the benchmark. It tells you when the tool will quietly do less than you expect. A load from STDIN cannot be parallelized the same way because there is no seekable file to read once. A load with a FILTER or a CHECK constraint needs the serial path to preserve the exact semantics. A load that tolerates parse errors needs a single place to count and report them. The fallback is not a failure; it is the tool being honest about what it can guarantee.
For operators, the practical lesson is to read the INFO line. If a production load falls back, the performance may be close to the serial path, and the benchmark numbers will not apply. The tool still works, but the capacity planning changes. A load that was expected to finish in 1.4 seconds may take 5.8 seconds. That is a big difference if the load is part of a nightly window.
The fallback design also affects testing. A test suite that only covers the parallel path will miss the serial behavior. A test suite that only covers the serial path will miss the parallel-specific bugs. The matrix needs both, plus the cases that trigger the fallback, because those are the cases where the tool's behavior changes without an error.
Where the speedup comes from, and where it stops
The speedup comes from parsing. On a CSV file, the parse step is CPU-intensive, and it is embarrassingly parallel if the file can be split into chunks. The reader hands out chunks, the workers parse them, and the leader inserts the results. With 15 workers on a 16-vCPU machine, the parse stage is no longer the bottleneck.
The insert stage is still serial. The leader has to fill pages, write WAL, and maintain the table's visibility. In the benchmark, the leader's serial insert sets a floor of about 1.37 seconds per GiB. At that point, the bottleneck is page fill plus WAL, not parsing. Adding more parser workers will not help. The only way to go faster is to make the insert itself faster, which is a much harder problem.
Indexes make the ceiling lower. Index maintenance during a load costs about 1.9 seconds per GiB for one btree, and it does not parallelize. If a table has several indexes, the index work can dominate the load. pg_fastload's SKIP_INDEX=ON option drops secondary indexes inside the load transaction and prints the CREATE INDEX statements to recreate them. That can recover about half the load time on an indexed table, but it is a trade-off: the table is unprotected during the load, and the index rebuild happens afterward.
The tool refuses to drop constraint-backed indexes such as primary keys, unique constraints, and exclusion constraints. That is the right call. Dropping a primary key or a unique index silently would change the table's integrity guarantees, and a loader should not do that without an explicit decision. The operator can still choose to drop and recreate those indexes manually, but the tool does not make that choice for them.
Progress and snapshot fingerprints
The release also adds a cluster-wide progress view, pgfastload.pg_fastload_progress, with rows, bytes, rates, and elapsed time. When the row total is known, it reports a percentage and an ETA. That is useful for long loads, and it is the kind of feature that matters more in production than a benchmark delta.
The export side has a similar improvement. pg_fastload_export() writes a table or a SELECT to CSV, binary, or fixed output. The export logs record the MVCC snapshot fingerprint, including xmin, xmax, and cid. That makes each output file auditable back to the exact snapshot that produced it. If the export runs while other transactions are writing, the snapshot fingerprint tells you which version of the data you got. That is a small feature with a large operational payoff.
The export scan runs under one MVCC snapshot and is serialized to the parallel workers. That means an export under concurrent writes is consistent and reproducible. The benchmark reports 7.4 million rows, or 1.13 GiB, taking 4.08 seconds serially and 0.42 seconds with 15 workers, a 9.33x improvement over server-side COPY TO. The same caveat applies: the export is parallel, but the snapshot semantics are preserved.
When to use it, and when COPY is enough
pg_fastload is a good fit for large, parse-heavy CSV loads into an unindexed or lightly indexed table, where the data is in a file and the load can tolerate a serial insert. It is also a good fit when you need one transaction and cannot use a staged or unlogged table. The progress view and snapshot fingerprint make it easier to operate.
COPY is still the right choice for small loads, loads from STDIN, loads with complex constraints, and environments where installing a source-level fork is not practical. COPY is part of PostgreSQL, it is well tested, and it has no extra operational surface. The fact that pg_fastload is faster on a 1 GiB benchmark does not mean it is faster on a 10 MB file or a table with five indexes.
The tool is a fork, not an extension. It has to be built against PostgreSQL 15 through 19, and it will need to be rebuilt for each major version. The release notes say one branch handles all five versions with compile-time differences, which reduces the maintenance burden, but it does not eliminate it. A team that adopts pg_fastload is taking on a dependency that tracks PostgreSQL's internals.
For a database team with a recurring bulk-load problem, that trade-off may be worth it. The architecture is sound, the benchmark is honest about its limits, and the operational features are useful. For a team that runs an occasional COPY, the built-in tool is still the better default. The interesting part of pg_fastload is not the 6x headline. It is the demonstration that you can parallelize the expensive part of a load without giving up the transaction semantics that make the load safe.
Sources
- pg_fastload 1.0.0 released: parallel bulk loading for PostgreSQL — PostgreSQL News, 2026-11-17
- pg_fastload v1.0.0 release — GitHub