Skip to content

: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.

perf(signals): index signal reports by team and updated_at (#126072)

posthog[bot]de2180e43b8b
diff --git a/products/signals/backend/migrations/0222_signalreport_team_updated_idx.py b/products/signals/backend/migrations/0222_signalreport_team_updated_idx.py
new file mode 100644
index 000000000000..9deb9e4804ef
--- /dev/null
+++ b/products/signals/backend/migrations/0222_signalreport_team_updated_idx.py
@@ -0,0 +1,16 @@
+from django.db import migrations, models
+
+from posthog.migration_helpers import SafeAddIndexConcurrently
+
+
+class Migration(migrations.Migration):
+ atomic = False
+
+ dependencies = [("signals", "0221_signal_filter_catalog")]
+
+ operations = [
+ SafeAddIndexConcurrently(
+ model_name="signalreport",
+ index=models.Index(fields=["team", "-updated_at", "id"], name="signals_report_team_updated"),
+ ),
+ ]
diff --git a/products/signals/backend/migrations/max_migration.txt b/products/signals/backend/migrations/max_migration.txt
index ec3fdca4697f..e9c35945ec9d 100644
--- a/products/signals/backend/migrations/max_migration.txt
+++ b/products/signals/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0221_signal_filter_catalog
+0222_signalreport_team_updated_idx
diff --git a/products/signals/backend/models.py b/products/signals/backend/models.py
index a203e24ef8a3..da8ecce1fb4e 100644
--- a/products/signals/backend/models.py
+++ b/products/signals/backend/models.py
@@ -521,6 +521,8 @@ class SignalReport(UUIDModel):
indexes = [
models.Index(fields=["team", "status", "promoted_at"]),
models.Index(fields=["team", "created_at"]),
+ # Back the inbox list ordered by `-updated_at`. The view appends `id` as a tie-breaker.
+ models.Index(fields=["team", "-updated_at", "id"], name="signals_report_team_updated"),
# Partial: the daily-limit gate only ever counts stamped rows for one team and day.
models.Index(
fields=["team", "first_visible_at"],