Why you shouldn't do application-level sharding
Application-level sharding of an OLTP database looks simple on day one (a `shard_for(user_id % N)` function) but accumulates serious engineering burdens as a system grows.
Application-level sharding of an OLTP database looks simple on day one (a `shard_for(user_id % N)` function) but accumulates serious engineering burdens as a system grows.
PlanetScale ran its Insights Agent, which finds costly queries via Query Insights and opens fix PRs, against its own Rails API on MySQL.
PlanetScale's open-source Heroku Migrator moves multi-terabyte Postgres databases off Heroku standard plans, which lack WAL access and logical replication, by using Bucardo trigger-based replication: triggers record changes in delta tables, a one-time COPY loads existing data, and a worker replays the backlog before a controlled switchover with verification.
Neki's shard groups co-locate related Postgres tables by hashing a shared shard key (e.g. customer_id via xxhash) into a 64-bit keyspace split across shards, so joins and transactions for one customer stay on a single shard with full Postgres semantics.
Postgres ON DELETE CASCADE turns a single-row delete into an unbounded transaction that can cause outages at scale.
PlanetScale Postgres and Neki databases can now run in three Azure regions (centralus, eastus2, westeurope), with the same HA across three availability zones, Query Insights, backups and NVMe-backed Metal clusters as on AWS and GCP.
Postgres TOAST kicks in once a row exceeds 2,032 bytes, compressing variable-length values largest-first and moving them into chunked pg_toast tables (1,996-byte chunks, 18-byte in-row pointers) when compression isn't enough.
TIN v1.0.6, PlanetScale's Postgres full-text search index, adds Snowball-based stemming for 18 languages via the rust_stemmers crate and extends its block-max top-k plan to queries with heap-attribute tiebreakers in ORDER BY.
Leaky buckets, descended from Bronze Age water clocks, remain a cheap admission-control mechanism: a bucket stores only its last level and timestamp, so its current level can be computed lazily as max(0, level_then − drain_rate × elapsed).
When a shard key like tenant_id stops matching reality because a few whale tenants dominate load or cross-tenant queries appear, Neki (PlanetScale's sharded Postgres from the Vitess maintainers) offers three escalating fixes: vertically scale the hot shard with its own configuration profile, isolate the whale by narrowing hashed key ranges in the declarative data topology, or reshard specific tables by a better key.
Choosing between aarch64 and x86-64 for a Postgres cluster matters because vCPUs differ: x86 cloud vCPUs are usually hyperthreads sharing a core, while Graviton and Axion vCPUs are full cores.
Inverted indexes power full-text search by mapping each term to a sorted, compressed postings list of document IDs, with optional positional data for phrase/span queries and frequency statistics for BM25 scoring.
PlanetScale Postgres blocks planned cutovers (resizes, parameter changes, maintenance) when logical replication slots aren't synchronized to the replica being promoted, because vanilla Postgres will promote a replica without the slot and silently break CDC consumers.
Neki shards unmodified PostgreSQL behind a single connection string.
PlanetScale replaced its weekly cron-based cherry-picking and its conflict-replaying git-replay tool with a stateful Vitess cherry-pick bot that continuously syncs OSS Vitess into a private fork.
MySQL's native INPLACE online DDL is unsuitable for non-blocking changes because it is resource-greedy, uninterruptible and blocks replicas, causing replication lag as long as the original ALTER.