Skip to content

Commit 6382448

Browse files
committed
For bulk write operations (eg COPY IN), use a ring buffer of 16MB instead
of the 256KB limit originally enforced by a patch committed 2008-11-06. Per recent test results, the smaller size resulted in an undesirable decrease in bulk data loading speed, due to COPY processing frequently getting blocked for WAL flushing. This area might need more tweaking later, but this setting seems to be good enough for 8.4.
1 parent 3f1e529 commit 6382448

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/backend/storage/buffer/README

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$PostgreSQL: pgsql/src/backend/storage/buffer/README,v 1.16 2009/02/18 15:58:41 heikki Exp $
1+
$PostgreSQL: pgsql/src/backend/storage/buffer/README,v 1.17 2009/06/22 20:04:28 tgl Exp $
22

33
Notes About Shared Buffer Access Rules
44
======================================
@@ -237,7 +237,12 @@ buffer, resulting in excessive WAL flushing. Allowing VACUUM to update
237237

238238
Bulk writes work similarly to VACUUM. Currently this applies only to
239239
COPY IN and CREATE TABLE AS SELECT. (Might it be interesting to make
240-
seqscan UPDATE and DELETE use the bulkwrite strategy?)
240+
seqscan UPDATE and DELETE use the bulkwrite strategy?) For bulk writes
241+
we use a ring size of 16MB (but not more than 1/8th of shared_buffers).
242+
Smaller sizes have been shown to result in the COPY blocking too often
243+
for WAL flushes. While it's okay for a background vacuum to be slowed by
244+
doing its own WAL flushing, we'd prefer that COPY not be subject to that,
245+
so we let it use up a bit more of the buffer arena.
241246

242247

243248
Background Writer's Processing

src/backend/storage/buffer/freelist.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/storage/buffer/freelist.c,v 1.66 2009/01/01 17:23:47 momjian Exp $
12+
* $PostgreSQL: pgsql/src/backend/storage/buffer/freelist.c,v 1.67 2009/06/22 20:04:28 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -368,9 +368,7 @@ GetAccessStrategy(BufferAccessStrategyType btype)
368368
int ring_size;
369369

370370
/*
371-
* Select ring size to use. See buffer/README for rationales. (Currently
372-
* all cases are the same size, but keep this code structure for
373-
* flexibility.)
371+
* Select ring size to use. See buffer/README for rationales.
374372
*
375373
* Note: if you change the ring size for BAS_BULKREAD, see also
376374
* SYNC_SCAN_REPORT_INTERVAL in access/heap/syncscan.c.
@@ -385,7 +383,7 @@ GetAccessStrategy(BufferAccessStrategyType btype)
385383
ring_size = 256 * 1024 / BLCKSZ;
386384
break;
387385
case BAS_BULKWRITE:
388-
ring_size = 256 * 1024 / BLCKSZ;
386+
ring_size = 16 * 1024 * 1024 / BLCKSZ;
389387
break;
390388
case BAS_VACUUM:
391389
ring_size = 256 * 1024 / BLCKSZ;

0 commit comments

Comments
 (0)