diff options
author | Andres Freund <andres@anarazel.de> | 2017-09-19 22:03:48 -0700 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2017-09-19 22:03:48 -0700 |
commit | fc49e24fa69a15efacd5b8958115ed9c43c48f9a (patch) | |
tree | a1399d0d533c1cfa864e545a17000e7b6df6f43d /src/backend/utils/misc/guc.c | |
parent | 5ada1fcd0c30be1b0b793a802cf6da386a6c1925 (diff) | |
download | postgresql-fc49e24fa69a15efacd5b8958115ed9c43c48f9a.tar.gz postgresql-fc49e24fa69a15efacd5b8958115ed9c43c48f9a.zip |
Make WAL segment size configurable at initdb time.
For performance reasons a larger segment size than the default 16MB
can be useful. A larger segment size has two main benefits: Firstly,
in setups using archiving, it makes it easier to write scripts that
can keep up with higher amounts of WAL, secondly, the WAL has to be
written and synced to disk less frequently.
But at the same time large segment size are disadvantageous for
smaller databases. So far the segment size had to be configured at
compile time, often making it unrealistic to choose one fitting to a
particularly load. Therefore change it to a initdb time setting.
This includes a breaking changes to the xlogreader.h API, which now
requires the current segment size to be configured. For that and
similar reasons a number of binaries had to be taught how to recognize
the current segment size.
Author: Beena Emerson, editorialized by Andres Freund
Reviewed-By: Andres Freund, David Steele, Kuntal Ghosh, Michael
Paquier, Peter Eisentraut, Robert Hass, Tushar Ahuja
Discussion: https://postgr.es/m/CAOG9ApEAcQ--1ieKbhFzXSQPw_YLmepaa4hNdnY5+ZULpt81Mw@mail.gmail.com
Diffstat (limited to 'src/backend/utils/misc/guc.c')
-rw-r--r-- | src/backend/utils/misc/guc.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index bc9f09a0868..e1fd446ce51 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -514,7 +514,6 @@ static int block_size; static int segment_size; static int wal_block_size; static bool data_checksums; -static int wal_segment_size; static bool integer_datetimes; static bool assert_enabled; @@ -714,9 +713,6 @@ typedef struct #if XLOG_BLCKSZ < 1024 || XLOG_BLCKSZ > (1024*1024) #error XLOG_BLCKSZ must be between 1KB and 1MB #endif -#if XLOG_SEG_SIZE < (1024*1024) || XLOG_SEG_SIZE > (1024*1024*1024) -#error XLOG_SEG_SIZE must be between 1MB and 1GB -#endif static const char *memory_units_hint = gettext_noop("Valid units for this parameter are \"kB\", \"MB\", \"GB\", and \"TB\"."); @@ -2264,7 +2260,8 @@ static struct config_int ConfigureNamesInt[] = GUC_UNIT_MB }, &min_wal_size_mb, - 5 * (XLOG_SEG_SIZE / (1024 * 1024)), 2, MAX_KILOBYTES, + DEFAULT_MIN_WAL_SEGS * (DEFAULT_XLOG_SEG_SIZE / (1024 * 1024)), + 2, MAX_KILOBYTES, NULL, NULL, NULL }, @@ -2275,7 +2272,8 @@ static struct config_int ConfigureNamesInt[] = GUC_UNIT_MB }, &max_wal_size_mb, - 64 * (XLOG_SEG_SIZE / (1024 * 1024)), 2, MAX_KILOBYTES, + DEFAULT_MAX_WAL_SEGS * (DEFAULT_XLOG_SEG_SIZE / (1024 * 1024)), + 2, MAX_KILOBYTES, NULL, assign_max_wal_size, NULL }, @@ -2637,14 +2635,14 @@ static struct config_int ConfigureNamesInt[] = { {"wal_segment_size", PGC_INTERNAL, PRESET_OPTIONS, - gettext_noop("Shows the number of pages per write ahead log segment."), + gettext_noop("Shows the size of write ahead log segments."), NULL, - GUC_UNIT_XBLOCKS | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE + GUC_UNIT_BYTE | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE }, &wal_segment_size, - (XLOG_SEG_SIZE / XLOG_BLCKSZ), - (XLOG_SEG_SIZE / XLOG_BLCKSZ), - (XLOG_SEG_SIZE / XLOG_BLCKSZ), + DEFAULT_XLOG_SEG_SIZE, + WalSegMinSize, + WalSegMaxSize, NULL, NULL, NULL }, |