TLDR · PROGRAMMING, DESIGN & DATA SCIENCE

KARPATHY'S AUTORESEARCH FOUND A 3-YEAR-OLD BUG IN POSTHOG'S QUERY ENGINE (AND IMPROVED PERFORMANCE BY 11%)

posthog.com9 min read

Summary from the TLDR newsletter

Posthog pointed an AI agent at its query agent, fed it slow queries from production, and let it run overnight. The next morning, the team discovered that for almost three years, every query with a timestamp filter had not been using ClickHouse's primary key correctly. Fixing the issue cut the number of granules ClickHouse had to scan by 62% on the benchmark query and made the query itself meaningfully faster. This post discusses the team's setup, the bug itself, and PostHog's plans to automate this type of analysis.