: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(error-tracking): drop duplicate symbol set index, lower cleanup concurrency (#79780)
Eli Reismanf165d3b81772
diff --git a/products/error_tracking/backend/migrations/0022_drop_redundant_symbolset_team_ref_idx.py b/products/error_tracking/backend/migrations/0022_drop_redundant_symbolset_team_ref_idx.pynew file mode 100644index 000000000000..e55027e61be5--- /dev/null+++ b/products/error_tracking/backend/migrations/0022_drop_redundant_symbolset_team_ref_idx.py@@ -0,0 +1,25 @@+from django.db import migrations++from posthog.migration_helpers import SafeRemoveIndexConcurrently+++class Migration(migrations.Migration):+ # Concurrent index drops cannot run inside a transaction.+ atomic = False++ dependencies = [+ (+ "error_tracking",+ "0021_remove_errortrackingsettings_autocapture_exceptions_opt_in",+ ),+ ]++ operations = [+ # Duplicates `unique_ref_per_team` on the same (team_id, ref) columns. The unique+ # constraint serves every scan the workload issues against those columns, so the+ # only thing this index still costs is write amplification and ~106 GB.+ SafeRemoveIndexConcurrently(+ model_name="errortrackingsymbolset",+ name="posthog_err_team_id_927574_idx",+ ),+ ]diff --git a/products/error_tracking/backend/migrations/max_migration.txt b/products/error_tracking/backend/migrations/max_migration.txtindex 4e8591f54105..3bb156feabe2 100644--- a/products/error_tracking/backend/migrations/max_migration.txt+++ b/products/error_tracking/backend/migrations/max_migration.txt@@ -1 +1 @@-0021_remove_errortrackingsettings_autocapture_exceptions_opt_in+0022_drop_redundant_symbolset_team_ref_idxdiff --git a/products/error_tracking/backend/models.py b/products/error_tracking/backend/models.pyindex add8a61abd53..1bfbb00a1ef3 100644--- a/products/error_tracking/backend/models.py+++ b/products/error_tracking/backend/models.py@@ -368,8 +368,9 @@ class ErrorTrackingSymbolSet(UUIDTModel):delete_symbol_set_contents(storage_ptr)class Meta:+ # No (team_id, ref) index here on purpose: `unique_ref_per_team` below already+ # provides one on the same columns, so a second is pure write and storage cost.indexes = [- models.Index(fields=["team_id", "ref"]),# Composite covers the cleanup filter's two OR branches: `last_used < cutoff`# (leading column) and `last_used IS NULL AND created_at < cutoff` (NULL group# then created_at range), so batch cleanup avoids a full PK-ordered scan.diff --git a/products/error_tracking/backend/temporal/symbol_set_cleanup/test/test_symbol_set_cleanup.py b/products/error_tracking/backend/temporal/symbol_set_cleanup/test/test_symbol_set_cleanup.pyindex 6e95b0d090a7..f07257f588d7 100644--- a/products/error_tracking/backend/temporal/symbol_set_cleanup/test/test_symbol_set_cleanup.py+++ b/products/error_tracking/backend/temporal/symbol_set_cleanup/test/test_symbol_set_cleanup.py@@ -205,7 +205,7 @@ class TestSymbolSetCleanupWorkflow:delete_unused=True,total_per_run=1000000,batch_size=10000,- parallelism=8,+ parallelism=4,dry_run=False,)diff --git a/products/error_tracking/backend/temporal/symbol_set_cleanup/types.py b/products/error_tracking/backend/temporal/symbol_set_cleanup/types.pyindex 877a50d0c5e6..66a73a7a8144 100644--- a/products/error_tracking/backend/temporal/symbol_set_cleanup/types.py+++ b/products/error_tracking/backend/temporal/symbol_set_cleanup/types.py@@ -7,7 +7,10 @@ class SymbolSetCleanupInputs:delete_unused: bool = Truetotal_per_run: int = 1000000batch_size: int = 10000- parallelism: int = 8+ # Workers contend rather than divide: they take `FOR UPDATE SKIP LOCKED` over the same+ # ordered range, so each one pays the full traversal and skips what the others hold.+ # `total_per_run` caps throughput regardless, so fewer workers spend less to reach it.+ parallelism: int = 4dry_run: bool = False