Sunday 12 February 2012

Wal growth calculation pg_xlog directory



There will always be at least one WAL segment file, and will normally not be more than (2 + checkpoint_completion_target) * checkpoint_segments + 1 or 2*checkpoint_segments + wal_keep_segments+ 1 files. Each segment file is normally 16 MB (though this size can be altered when building the server). You can use this to estimate space requirements for WAL. Ordinarily, when old log segment files are no longer needed, they are recycled (renamed to become the next segments in the numbered sequence).

 If, due to a short-term peak of log output rate, there are more than 3 *checkpoint_segments + 1 segment files, the unneeded segment files will be deleted instead of recycled until the system gets back under this limit.


Based on the below mentioned formula we can calculate the pg_xlog growth.
checkpoint_completion_target=0.5
checkpoint_segments         =256
wal_keep_segments =128

F1=(2+0.5)*256+1=642.5
F2=2*256+128=640
F3=(3*256)+1=768

Based on this pg xlog wall files will grow upto  642 pg xlog files normal scenario and 768 critical scenario due to short term peak transactions.

When ever we perform huge update and delete operation on a tables that time these log files will grow upto this level.

No comments:

Post a Comment