HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlModerate

Understanding "max_wal_size" and "min_wal_size" parameters default values from postgresql.conf file

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
min_wal_sizeunderstandingpostgresqlconfvaluesfilemax_wal_sizedefaultandfrom

Problem

Default values are, according to documentation for min_wal_size and max_wal_size parameters:

For max_wal_size: The default is 1 GB

For min_wal_size: The default is 80 MB

Then I look this parameters from my database config:

select name, setting, unit 
from pg_settings 
where name in ('min_wal_size', 'max_wal_size')


Gives result:

name         |  setting | unit
----------------------------------
max_wal_size | 64       | 
min_wal_size | 5        |


I have 2 questions:

1) Why these values doesn't match default values, which are shown in docs? I never changed config settings at all.

2) Why unit column is empty/NULL for these parameters? What means 64 and 5 values in this case? MB? GB? Or what?

Why this is not like for example work_mem parameter, when everything is clear:

name         | setting  | unit
----------------------------------
work_mem     | 4096     | kB

Solution

These are 16 MB WAL segments by default. The manual:


The system physically divides this sequence into WAL segment files,
which are normally 16MB apiece (although the segment size can be
altered when building PostgreSQL)

So, it's just default values as advertised:

select name, setting, setting::int * 16 || 'MB' AS setting_in_mb
from pg_settings 
where name in ('min_wal_size', 'max_wal_size');


unit in pg_settings is present when it's an actual base unit like second or MB. In this case the "unit" would be "WAL segments", which can be configured before compiling Postgres. The unit column is just NULL for those.

Code Snippets

select name, setting, setting::int * 16 || 'MB' AS setting_in_mb
from pg_settings 
where name in ('min_wal_size', 'max_wal_size');

Context

StackExchange Database Administrators Q#151341, answer score: 18

Revisions (0)

No revisions yet.