Dirty buffer throttling v16
EDB Resource Manager uses dirty buffer throttling to keep the aggregate shared buffer writing rate of all processes in the group near the limit specified by the dirty_rate_limit
parameter. A process in the group might be interrupted and put into sleep mode for a short time to maintain the defined limit. When and how such interruptions occur is defined by a proprietary algorithm used by EDB Resource Manager.
To control writing to shared buffers, set the dirty_rate_limit
resource type parameter.
Set the
dirty_rate_limit
parameter to the number of kilobytes per second for the combined rate at which all the processes in the group write to, or “dirty”, the shared buffers. An example setting is 3072 kilobytes per seconds.The valid range of the
dirty_rate_limit
parameter is 0 to 1.67772e+07. A setting of 0 means no dirty rate limit was set for the resource group.
Setting the dirty rate limit for a resource group
Use the ALTER RESOURCE GROUP
command with the SET dirty_rate_limit
clause to set the dirty rate limit for a resource group.
In this example, the dirty rate limit is set to 12288 kilobytes per second for resgrp_a
, 6144 kilobytes per second for resgrp_b
, and 3072 kilobytes per second for resgrp_c
. This means that the combined writing rate to the shared buffer of all processes assigned to resgrp_a
is maintained at approximately 12288 kilobytes per second. Similarly, for all processes in resgrp_b
, the combined writing rate to the shared buffer is kept to approximately 6144 kilobytes per second, and so on.
This query shows the settings of dirty_rate_limit
in the catalog;
Changing the dirty rate limit
Changing the dirty_rate_limit
of a resource group affects new processes that are assigned to the group. Any currently running processes that are members of the group are also immediately affected by the change. That is, if the dirty_rate_limit
is changed from 12288 to 3072, currently running processes in the group are throttled downward so that the aggregate group dirty rate is near 3072 kilobytes per second instead of 12288 kilobytes per second.
To show the effect of setting the dirty rate limit for resource groups, the examples use the following table for intensive I/O operations:
The FILLFACTOR = 10
clause results in INSERT
commands packing rows up to only 10% per page. The result is a larger sampling of dirty shared blocks for the purpose of these examples.
Displaying the number of dirty buffers
The pg_stat_statements
module is used to display the number of shared buffer blocks that are dirtied by a SQL command and the amount of time the command took to execute. This information is used to calculate the actual kilobytes per second writing rate for the SQL command and thus compare it to the dirty rate limit set for a resource group.
To use the pg_stat_statements
module:
In the
postgresql.conf
file, add$libdir/pg_stat_statements
to theshared_preload_libraries
configuration parameter: