Sequences and other volatiles in Neki
Blog post from PlanetScale
Mats Rydberg explains how Neki, PlanetScale’s sharded PostgreSQL system, reproduces PostgreSQL sequence semantics despite distributing data across independent shards. Neki pushes work to shards when possible but reserves router-only evaluation for expressions whose results require global consistency, such as stable functions like now(), which must return one statement-wide timestamp, and volatile functions like nextval(), which must generate a distinct sequence value for every evaluated row. Because sequences on separate shards could otherwise create duplicate values, Neki centralizes allocation through an authoritative sequence host and distributes generated values from the router. The system must also preserve expression cardinality, ensuring volatile expressions are evaluated once per resulting table-expression row even when joins, filters, or optimizations change intermediate execution order. For distributed SELECT queries, Neki can perform shard-local joins and immutable calculations remotely while applying stable and volatile expressions over the combined result stream in the router. For UPDATE operations using nextval(), it first identifies and locks affected rows, generates a sequence value for each row centrally, and then sends parameterized updates to the appropriate shards.
No tracked trend matches for this post yet.
Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.