: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(slack): index posthog_integration on (kind, integration_id) (#84426)
Ben White3612cfa31399
diff --git a/posthog/migrations/1309_integration_kind_ext_idx.py b/posthog/migrations/1309_integration_kind_ext_idx.pynew file mode 100644index 000000000000..d47dd19818a2--- /dev/null+++ b/posthog/migrations/1309_integration_kind_ext_idx.py@@ -0,0 +1,26 @@+from django.db import migrations, models++from posthog.migration_helpers import SafeAddIndexConcurrently+++class Migration(migrations.Migration):+ """+ Every inbound Slack webhook resolves its PostHog project by (kind, integration_id), because the+ payload names the Slack workspace and nothing else. The only index covering those columns is the+ `posthog_integration_kind_id_unique` constraint, which leads with `team`, so that lookup can't+ use it.++ Built with CREATE INDEX CONCURRENTLY (SHARE UPDATE EXCLUSIVE) rather than a plain AddIndex, so+ reads and writes on posthog_integration keep running while it builds.+ """++ atomic = False++ dependencies = [("posthog", "1308_githubinstallrequest")]++ operations = [+ SafeAddIndexConcurrently(+ model_name="integration",+ index=models.Index(fields=["kind", "integration_id"], name="posthog_integration_kind_ext"),+ ),+ ]diff --git a/posthog/migrations/max_migration.txt b/posthog/migrations/max_migration.txtindex af5a50124657..f2b78b04abc2 100644--- a/posthog/migrations/max_migration.txt+++ b/posthog/migrations/max_migration.txt@@ -1 +1 @@-1308_githubinstallrequest+1309_integration_kind_ext_idxdiff --git a/posthog/models/integration.py b/posthog/models/integration.pyindex 7832d18a3d07..52536c91d712 100644--- a/posthog/models/integration.py+++ b/posthog/models/integration.py@@ -639,6 +639,7 @@ class Integration(models.Model):fields=["team", "kind", "integration_id"], name="posthog_integration_kind_id_unique")]+ indexes = [models.Index(fields=["kind", "integration_id"], name="posthog_integration_kind_ext")]@propertydef display_name(self) -> str: