PlanetScale

The lifecycle of a sharded Postgres query

Sep 10, 2026
The lifecycle of a sharded Postgres query
SummaryAI, from the source post

This post details the query lifecycle through the Neki router, including authentication (SCRAM-SHA-256 in Go), protocol handling (Simple vs. Extended), parsing into an AST (18,000 lines of Go), and the sharded query planner's role in optimizing distributed queries across shards. It highlights the challenges of sharding, such as non-co-located related data, and the planner's 'laziness' in minimizing work by caching plans and understanding schema and data distribution rules.

More from the Neki Query Performance trail