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.

fix(error-tracking): index stack frames by team and created_at (#92228)

José Sequeira8c23f587b262
diff --git a/products/error_tracking/backend/migrations/0030_add_stackframe_team_created_at_index.py b/products/error_tracking/backend/migrations/0030_add_stackframe_team_created_at_index.py
new file mode 100644
index 000000000000..2eab429eb798
--- /dev/null
+++ b/products/error_tracking/backend/migrations/0030_add_stackframe_team_created_at_index.py
@@ -0,0 +1,18 @@
+from django.db import migrations, models
+
+from posthog.migration_helpers import SafeAddIndexConcurrently
+
+
+class Migration(migrations.Migration):
+ atomic = False
+
+ dependencies = [
+ ("error_tracking", "0029_remove_symbolset_used_created_index"),
+ ]
+
+ operations = [
+ SafeAddIndexConcurrently(
+ model_name="errortrackingstackframe",
+ index=models.Index(fields=["team", "created_at"], name="et_frame_team_created_at_idx"),
+ ),
+ ]
diff --git a/products/error_tracking/backend/migrations/max_migration.txt b/products/error_tracking/backend/migrations/max_migration.txt
index 919160ae320a..b7dd3d4d8c62 100644
--- a/products/error_tracking/backend/migrations/max_migration.txt
+++ b/products/error_tracking/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0029_remove_symbolset_used_created_index
+0030_add_stackframe_team_created_at_index
diff --git a/products/error_tracking/backend/models.py b/products/error_tracking/backend/models.py
index 7be036471198..490fe0ae3930 100644
--- a/products/error_tracking/backend/models.py
+++ b/products/error_tracking/backend/models.py
@@ -613,7 +613,11 @@ class ErrorTrackingStackFrame(UUIDTModel):
context = models.JSONField(null=True, blank=True)
class Meta:
- indexes = []
+ indexes = [
+ # Recent-frames-per-team scans, such as the source maps recommendation. Without
+ # created_at in the index, a 24h window has to visit every frame the team ever stored.
+ models.Index(fields=["team", "created_at"], name="et_frame_team_created_at_idx"),
+ ]
constraints = [
models.UniqueConstraint(fields=["team_id", "raw_id", "part"], name="unique_team_id_raw_id_part"),