:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
perf(signals): lower autovacuum scale factor on scout config table (#117489)
posthog[bot]4d125671c83c
diff --git a/products/signals/backend/migrations/0178_signalscoutconfig_autovacuum_scale_factor.py b/products/signals/backend/migrations/0178_signalscoutconfig_autovacuum_scale_factor.pynew file mode 100644index 000000000000..14e9d5aec412--- /dev/null+++ b/products/signals/backend/migrations/0178_signalscoutconfig_autovacuum_scale_factor.py@@ -0,0 +1,34 @@+from django.db import migrations++# The table is small, but every scout run rewrites its rows: the coordinator stamps `last_run_at`+# on each dispatch, the runner counts failed runs in `consecutive_failure_count`, and status changes+# and rubric saves add more updates. The global scale factor of 0.1 lets dead tuples build up+# between passes, which pganalyze flags as insufficient vacuuming. 0.02 matches the other tuned+# product tables, and the matching analyze factor keeps the planner statistics current.+#+# SET (...) takes SHARE UPDATE EXCLUSIVE, which does not conflict with the scout config writes.+TABLE = "signals_signalscoutconfig"+SCALE_FACTOR = 0.02+++class Migration(migrations.Migration):+ dependencies = [+ ("signals", "0177_backfill_scout_notebook_write"),+ ]++ operations = [+ migrations.RunSQL(+ sql=[+ # Fail fast rather than queue: this waits behind an in-progress autovacuum+ # on the same table, and a retry is cheaper than holding the lock request.+ "SET LOCAL lock_timeout = '5s'",+ f"ALTER TABLE {TABLE} SET ("+ f"autovacuum_vacuum_scale_factor = {SCALE_FACTOR}, "+ f"autovacuum_analyze_scale_factor = {SCALE_FACTOR})",+ ],+ reverse_sql=[+ "SET LOCAL lock_timeout = '5s'",+ f"ALTER TABLE {TABLE} RESET (autovacuum_vacuum_scale_factor, autovacuum_analyze_scale_factor)",+ ],+ ),+ ]diff --git a/products/signals/backend/migrations/max_migration.txt b/products/signals/backend/migrations/max_migration.txtindex f3d02872cdd2..a93b96b4bf15 100644--- a/products/signals/backend/migrations/max_migration.txt+++ b/products/signals/backend/migrations/max_migration.txt@@ -1 +1 @@-0177_backfill_scout_notebook_write+0178_signalscoutconfig_autovacuum_scale_factor