Skip to content

fix(scheduler): decrease tasks table autovacuum factor settings #4021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2025

Conversation

TBonnin
Copy link
Collaborator

@TBonnin TBonnin commented May 9, 2025

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)
Screenshot 2025-05-09 at 10 56 32


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

@TBonnin TBonnin requested a review from a team May 9, 2025 15:03
Copy link

cubic-dev-ai bot commented May 9, 2025

Your mrge subscription is currently inactive. Please reactivate your subscription to receive AI reviews and use mrge.

@NangoHQ NangoHQ deleted a comment from propel-code-bot bot May 9, 2025
Copy link
Collaborator

@bodinsamuel bodinsamuel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PG's defaults are not really good 😓

@TBonnin TBonnin enabled auto-merge (squash) May 12, 2025 13:05
@TBonnin TBonnin force-pushed the tbonnin/may-9/tasks-autovacuum branch 2 times, most recently from 1049abc to 26ff14c Compare May 12, 2025 13:13
The performance of the expireTasks query decreases over time until
vacuuming occurs and speed of the query is back to its baseline.
The tasks table update rate is very high (ex: frequent state and dates updates)
and create table bloat.
This commit is an attempts 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 arbitrarely. I will keep monitoring the scheduler queries
@TBonnin TBonnin force-pushed the tbonnin/may-9/tasks-autovacuum branch from 26ff14c to 3725226 Compare May 12, 2025 13:33
@TBonnin TBonnin merged commit b87c5ba into master May 12, 2025
17 of 18 checks passed
@TBonnin TBonnin deleted the tbonnin/may-9/tasks-autovacuum branch May 12, 2025 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants