TLDRocket
Sign in

I wrote a 70x faster SQL parser while barely looking at the code

posthog.com

PostHog rewrote its SQL parser using Claude AI in parallel coding sessions, producing 16K lines of hand-rolled Rust code that achieves 454x faster performance than the previous ANTLR-based C++ parser on production queries. The developer used property-based testing with a custom SQL generator based on the grammar file, along with code-coverage-guided fuzzing and production corpus testing, to ensure the new parser matched the oracle parser's behavior on millions of queries. The rewrite—which would have taken months without AI assistance—demonstrates that LLM-assisted hand-written parsers can outperform generated parser frameworks.

Why it matters

A new SQL parser for PostHog was developed using AI with a huge speed improvement compared to the previous C++ based ANTLR parser. The process involved using property-based testing for generating and validating test cases, alongside prompt engineering to guide the AI in implementing the parser.

Related stories

The daily briefing

Every AI story that matters, in your inbox by 8am.

TLDRocket reads all relevant sources, removes duplicate coverage, and summarises the day in two minutes. Follow companies and topics for alerts, or get the briefing in Slack. Free, no spam, unsubscribe anytime.