Skip to content
PlanetScale
PlanetScale logoPlanetScale · Feature trail

Neki Query Performance

26 posts · Jun 2022 – Oct 2026

What this trail covers

Neki, PlanetScale's sharded Postgres solution, continues to evolve its architecture. This post details optimizations in query processing by minimizing unnecessary data decoding and serialization. The router now selectively decodes only required columns and parameters, and preserves original PostgreSQL wire formats where possible. This lazy and composable approach reduces network hops and processing overhead, especially for point lookups, queries with LIMIT, and cross-shard queries where full row decoding is avoided. New features include read-only replicas for shards, smaller Metal instances, and enhanced Terraform/CLI management for Neki extensions and router parameters. Support for Azure regions has also been added. Under the hood, significant engineering effort has focused on the query layer, expanding SQL compatibility to include features like INSERT ... SELECT ... ON CONFLICT, cross-shard UPDATE ... FROM, DELETE ... USING, MERGE, correlated EXISTS, ARRAY(SELECT ...), SQL cursors, LISTEN/NOTIFY, materialized views, and PL/pgSQL exception handlers. Exporting data with standard tools like pg_dump is now supported via `COPY ... TO STDOUT` on sharded tables. Bulk write performance has seen substantial improvements, with distributed INSERT ... SELECT being ~76x faster and COPY ingest ~5x faster. A new `EXPLAIN (NEKI_PG_PLAN)` command provides visibility into Neki's distributed plan alongside individual shard plans.

All PlanetScale trails