: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(data-modeling): index the latest-job-per-view lookup (#99882)
posthog[bot]c0f85a8598f0
diff --git a/products/data_modeling/backend/migrations/0041_datamodelingjob_sq_engine_run_idx.py b/products/data_modeling/backend/migrations/0041_datamodelingjob_sq_engine_run_idx.pynew file mode 100644index 000000000000..f49d43d961d7--- /dev/null+++ b/products/data_modeling/backend/migrations/0041_datamodelingjob_sq_engine_run_idx.py@@ -0,0 +1,18 @@+from django.db import migrations, models++from posthog.migration_helpers import SafeAddIndexConcurrently+++class Migration(migrations.Migration):+ atomic = False++ dependencies = [+ ("data_modeling", "0040_add_managed_warehouse_job_engine"),+ ]++ operations = [+ SafeAddIndexConcurrently(+ model_name="datamodelingjob",+ index=models.Index(fields=["saved_query", "engine", "-last_run_at"], name="datamodelingjob_sq_engine_run"),+ ),+ ]diff --git a/products/data_modeling/backend/migrations/max_migration.txt b/products/data_modeling/backend/migrations/max_migration.txtindex a2dd6943f96b..470afe775426 100644--- a/products/data_modeling/backend/migrations/max_migration.txt+++ b/products/data_modeling/backend/migrations/max_migration.txt@@ -1 +1 @@-0040_add_managed_warehouse_job_engine+0041_datamodelingjob_sq_engine_run_idxdiff --git a/products/data_modeling/backend/models/data_modeling_job.py b/products/data_modeling/backend/models/data_modeling_job.pyindex 7da49d78bf73..e1c97f402df7 100644--- a/products/data_modeling/backend/models/data_modeling_job.py+++ b/products/data_modeling/backend/models/data_modeling_job.py@@ -61,4 +61,7 @@ class DataModelingJob(CreatedMetaFields, UpdatedMetaFields, UUIDTModel):indexes = [# serves to cut lookup times for pre-existing running jobs during the preempt stagemodels.Index(fields=["team", "status"], name="datamodelingjob_team_status"),+ # serves the per-saved-query lookup of the latest job of one engine, which the+ # materialized view health check and failure digest do for every live view+ models.Index(fields=["saved_query", "engine", "-last_run_at"], name="datamodelingjob_sq_engine_run"),]