We made experiment queries 4x faster using precomputation
Blog post from PostHog
PostHog substantially improved Experiments query performance as customer data volumes and product complexity grew, reducing p95 latency from 18.9 seconds to 4.3 seconds, p99 latency from 91 seconds to 13.5 seconds, and query failures by 14 times while monthly query volume more than tripled. The main change was a precomputation system that stores reusable time-bucketed query results, allowing subsequent requests to scan only recent data; this reduced average data scanned per metric from 207 GB to 7.6 GB. Because cached and direct calculations needed to remain consistent despite late-arriving events and distributed ClickHouse behavior, the team added synchronous cache writes, corrected edge cases, and built production canary tests that compare both calculation paths nightly. Additional gains came from SQL changes that reduced duplicate event-table scans, disk-based joins that avoid memory failures, deferred reads for optional session-recording data, and a dedicated experiment-exposure event that is far smaller than the previously reused feature-flag event. PostHog also moved metric recalculation from browsers to Temporal workflows, preventing duplicate requests, enabling reliable retries, and improving user visibility into queued and running work. AI agents connected to monitoring and query logs shortened investigations of regressions and anomalies, while the team concluded that production validation and operational complexity became necessary once incremental SQL optimization could no longer meet customer demand.
| Trend | Post Mentions | Total Month Mentions | Posts | Companies | MoM |
|---|---|---|---|---|---|
| AI Agents | 1 | 2,121 | 373 | 132 | -70% |
Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.