Cost-based Vacuum Delay
This feature is designed to reduce the I/O impact of maintenance operations such as VACUUM and ANALYZE in high-concurrency databases. The cost-based vacuum delay mechanism enables administrators to balance resource allocation among maintenance tasks and normal service operations. This feature provides the following functions:
- Non-critical delay: Maintenance operations do not need to be completed immediately and can be executed in the backend.
- Resource isolation: Maintenance tasks are prevented from occupying too many I/O resources, ensuring service query performance.
Certain VACUUM operations hold critical locks and should be complete as quickly as possible. In GaussDB, cost-based vacuum delays do not take effect during such operations. To avoid uselessly long delays in such cases, the actual delay is the larger of the two calculated values:
- vacuum_cost_delay x accumulated_balance/vacuum_cost_limit
- vacuum_cost_delay x 4
Context
During the execution of the ANALYZE | ANALYSE and VACUUM statements, the system maintains an internal counter that keeps track of the estimated cost of the various I/O operations that are performed. When the accumulated I/O cost reaches the threshold specified by vacuum_cost_limit, the thread that performs the maintenance operation sleeps for the time specified by vacuum_cost_delay. After the sleep ends, the counter is reset, and the operation continues. This feature is disabled by default. You need to set vacuum_cost_delay to a non-zero value to enable it.
vacuum_cost_delay
Parameter description: VACUUM starts the backend worker thread to vacuum dead tuples in the data table, which conflicts with the worker thread. If vacuum_cost_delay is set to the value of vacuum_cost_limit to control the impact of VACUUM on services, the VACUUM thread hibernates the time specified by vacuum_cost_delay and allocates resources to worker threads for execution to ensure that services are not blocked by backend VACUUM.
Parameter type: integer.
Unit: milliseconds
Value range: 0 to 100. The value 0 indicates that the cost-based vacuum delay feature is disabled, and a positive value indicates that the cost-based vacuum delay feature is enabled. In many systems, the effective resolution of the hibernation time is 10 milliseconds. Therefore, setting vacuum_cost_delay to a value that is not an integer multiple of 10 has the same effect as setting it to the next higher multiple of 10.
Default value: 1
Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 1.
Setting suggestion: This parameter is usually set to a small value, such as 10ms or 20ms. Adjusting vacuum's resource consumption is best done by changing other vacuum cost parameters.
Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.
vacuum_cost_page_hit
Parameter description: Specifies the estimated cost for VACUUM to clean up data pages hit in a buffer.
Parameter type: integer.
Unit: none
Value range: 0 to 10000
Default value: 1
Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 1.
Setting suggestion: Retain the default value.
Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.
vacuum_cost_page_miss
Parameter description: Specifies the estimated cost for VACUUM to clean up data pages that do not hit in a buffer.
Parameter type: integer.
Unit: none
Value range: 0 to 10000
Default value: 10
Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 1.
Setting suggestion: Retain the default value.
Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.
vacuum_cost_page_dirty
Parameter description: Specifies the cost of VACUUM cleanup dirty pages. If the data page to be cleaned up is a clean page, VACUUM cleanup generates an extra cost of flushing dirty pages to disks. You can set this parameter to specify the cost of VACUUM cleanup dirty pages.
Parameter type: integer.
Unit: none
Value range: 0 to 10000
Default value: 20
Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 1.
Setting suggestion: Retain the default value.
Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.
vacuum_cost_limit
Parameter description: Specifies the cost limit. The vacuum thread will hibernate if this limit is exceeded. When the execution cost of the VACUUM thread reaches vacuum_cost_limit, the thread sleeps for the time specified by vacuum_cost_delay.
Parameter type: integer.
Unit: none
Value range: 1 to 10000
Default value: 1000
Setting method: This is a USERSET parameter. Set it based on instructions provided in Table 1.
Setting suggestion: Retain the default value. A larger value indicates a smaller I/O frequency limit of the VACUUM, a lower probability of entering the hibernation, more efficient VACUUM, and a greater impact on service I/Os.
Risks and impacts of improper settings: Change the parameter value after fully understanding the parameter meaning and verifying it through testing.
vacuum_defer_cleanup_age
Parameter description: Specifies the delay for the VACUUM operation to clear invalid row-store table records. The delay is calculated based on the number of executed transactions. You can set the value of vacuum_defer_cleanup_age to control the number of delayed transactions. That is, the VACUUM and VACUUM FULL operations do not clear a deleted tuple immediately. Instead, they clear and delete the tuple only after a certain number of transactions have been processed.
Parameter type: integer.
Unit: none
Value range: 0 to 1000000. 0 indicates no delay.
Default value: 0
Setting method: This is a SIGHUP parameter. Set it based on instructions provided in Table 1.
Setting suggestion: Retain the default value.
Risks and impacts of improper settings: If the value is too large, VACUUM and VACUUM FULL cannot be performed in a timely manner.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot