Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mirrorless: Enable WAL optimization for COPY FROM
CopyFrom has an optimization where WAL can be avoided if the COPY is in the same transaction as the CREATE and the data is being written to the same relfilenode created in this transaction. Unfortunately, this optimization was ifdefed out, due to legacy assumptions about our inability to support wal_level = minimal. Here is an example in a mirrorless demo cluster with wal_level = minimal: BEGIN; CREATE TABLE foo(i int) DISTRIBUTED REPLICATED; COPY foo FROM PROGRAM 'seq 1 3'; COMMIT; Without patch, WAL for this table: rmgr: Storage len (rec/tot): 46/ 46, tx: 0, lsn: 0/0C010D30, prev 0/0C010D10, desc: CREATE base/13720/32768; smgr: heap rmgr: Heap2 len (rec/tot): 86/ 86, tx: 540, lsn: 0/0C023C20, prev 0/0C023B88, desc: MULTI_INSERT+INIT 3 tuples flags 0x02, blkref #0: rel 1663/13720/32768 blk 0 With patch, WAL for this table (MULTI_INSERT record not emitted): rmgr: Storage len (rec/tot): 46/ 46, tx: 0, lsn: 0/0C004908, prev 0/0C0048E8, desc: CREATE base/13720/24576; smgr: heap PS: AO/CO tables avoid writing WAL for all inserts in a more general way, and this change doesn't affect them.
- Loading branch information