: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(marketing-analytics): skip adapter build on precompute hit (#67944)
Javier Bahamondes2d2e41351fc2
diff --git a/products/marketing_analytics/backend/hogql_queries/marketing_analytics_base_query_runner.py b/products/marketing_analytics/backend/hogql_queries/marketing_analytics_base_query_runner.pyindex e9a653e42aa3..24b3dea50ad1 100644--- a/products/marketing_analytics/backend/hogql_queries/marketing_analytics_base_query_runner.py+++ b/products/marketing_analytics/backend/hogql_queries/marketing_analytics_base_query_runner.py@@ -912,10 +912,6 @@ class MarketingAnalyticsBaseQueryRunner(AnalyticsQueryRunner[ResponseType], ABC,with self.timings.measure("ma_build_database"):_ = self._shared_hogql_database- # Get marketing source adapters- with self.timings.measure("ma_get_adapters"):- adapters = self._get_marketing_source_adapters(date_range=self.query_date_range)-# Build the cost source. When cost precompute is enabled, read the native materialized table# (no S3); fall back to the live S3 adapter union if not enabled or jobs aren't ready.union_subquery: ast.SelectQuery | ast.SelectSetQuery | None = None@@ -927,6 +923,10 @@ class MarketingAnalyticsBaseQueryRunner(AnalyticsQueryRunner[ResponseType], ABC,logger.exception("cost_precompute_failed", team_id=self.team.pk)union_subquery = Noneif union_subquery is None:+ # Only the S3 fallback consumes the live adapters. When precompute serves the query+ # they'd be built and thrown away, so defer construction into this branch.+ with self.timings.measure("ma_get_adapters"):+ adapters = self._get_marketing_source_adapters(date_range=self.query_date_range)with self.timings.measure("ma_build_union_s3"):# AST form to skip parse_select.union_subquery = self._factory(date_range=self.query_date_range).build_union_query_ast(adapters)