fix(scheduler): decrease tasks table autovacuum factor settings #4021
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
tl;dr: Squeeze more performance out of the orchestrator db
The tasks table update rate is very high (ex: frequent state and dates updates) and create table bloat,
causing the expireTasks query to slow down over time until vacuuming occurs and speed of the query is back to its baseline again.
This commit is an attempt at optimizing the autovacuum settings for the tasks table to trigger cleaning operations more frequently by reducing scale factors. (The pg default autovaccum settings are too high for the tasks table)
By vacuuming at 1% modified rows rather than the default 10%, we'll maintain more consistent query performance while preventing excessive dead tuple accumulation I choose the new value somehow arbitrarily. I will keep monitoring the scheduler queries
example of the effect of vacuuming (vacuuming is in pink)

This PR introduces a database migration that reduces autovacuum scale factors for the tasks table to prevent performance degradation. By decreasing threshold values (vacuum: 10%→1%, analyze: 5%→1%, insert: 20%→5%), the database will perform cleanup operations more frequently, reducing table bloat caused by high update rates.
This summary was automatically generated by @propel-code-bot