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(aio): index evaluation report runs on report and period_end (#113700)

posthog[bot]460c6e1b22a1
diff --git a/products/ai_observability/backend/migrations/0062_evaluationreportrun_period_end_index.py b/products/ai_observability/backend/migrations/0062_evaluationreportrun_period_end_index.py
new file mode 100644
index 000000000000..4be52a22bbb5
--- /dev/null
+++ b/products/ai_observability/backend/migrations/0062_evaluationreportrun_period_end_index.py
@@ -0,0 +1,21 @@
+from django.db import migrations, models
+
+from posthog.migration_helpers import SafeAddIndexConcurrently
+
+
+class Migration(migrations.Migration):
+ atomic = False
+
+ dependencies = [
+ ("ai_observability", "0061_backfill_condition_ids"),
+ ]
+
+ operations = [
+ SafeAddIndexConcurrently(
+ model_name="evaluationreportrun",
+ index=models.Index(
+ fields=["report", "-period_end"],
+ name="llma_eval_run_period_end_idx",
+ ),
+ ),
+ ]
diff --git a/products/ai_observability/backend/migrations/max_migration.txt b/products/ai_observability/backend/migrations/max_migration.txt
index 8438e40dc426..caf5eda2a86d 100644
--- a/products/ai_observability/backend/migrations/max_migration.txt
+++ b/products/ai_observability/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0061_backfill_condition_ids
+0062_evaluationreportrun_period_end_index
diff --git a/products/ai_observability/backend/models/evaluation_reports.py b/products/ai_observability/backend/models/evaluation_reports.py
index c3533b05b31c..7bddddb73b85 100644
--- a/products/ai_observability/backend/models/evaluation_reports.py
+++ b/products/ai_observability/backend/models/evaluation_reports.py
@@ -216,6 +216,7 @@ class EvaluationReportRun(UUIDTModel):
ordering = ["-created_at", "id"]
indexes = [
models.Index(fields=["report", "-created_at"]),
+ models.Index(fields=["report", "-period_end"], name="llma_eval_run_period_end_idx"),
]
report = models.ForeignKey(