Skip to content
Hacker News front page

PostHog rewrote its SQL parser with AI, 70x faster

I rewrote PostHog's SQL parser, 70x faster, while barely looking at the code

PostHog engineer Robbie Coomber used multiple parallel Claude Code sessions to rewrite the company's SQL parser from ANTLR-generated C++ into 16K lines of hand-rolled Rust, achieving a ~70x speedup. The old parser relied on ANTLR's graph-walking interpreter; the new one uses recursive descent with a Pratt expression loop and backtracking only where needed. Development was driven by an oracle approach: the old parser's output served as ground truth, and the team iterated by finding disagreeing SQL, fixing the new parser, and re-running tests. The new parser matches the old one on all realistic queries, diverging only on deliberately pathological cases like SELECT SELECT FROM FROM WHERE WHERE AND AND. The post does not disclose specific latency numbers, hardware, or how the 70x figure was measured.

Why it matters: A solid AI-assisted engineering writeup: rewrote PostHog's ANTLR-generated C++ SQL parser into 16k lines of hand-rolled Rust using Claude Code, 70x faster. Has concrete methodology and numbers, not marketing fluff. Capped at 78 because it's a single engineering blog post, not ...

Read the original ↗Export Markdown