What I measured before sharding a billion-row table
I ran the usual advice for huge tables on PostgreSQL 17: index depth, partition pruning, hash versus range shards, and a follower list stored as an array.
TECHNICAL BLOG
Write-ups from e-commerce backends I work on: what broke, how it was measured, and what changed. Most posts include the code and numbers to reproduce them.
I ran the usual advice for huge tables on PostgreSQL 17: index depth, partition pruning, hash versus range shards, and a follower list stored as an array.
On 12 injected faults, a restart passes the check and fails again when the load returns. A /health probe passed 110 of 120 runs where nobody did anything.
Eight design patterns from my 2022 exercises, rewritten in TypeScript and tested, with what the old versions got wrong and what I would use today.
Strict rotation caught a stolen token. In my tests it also logged out the real user on parallel requests, a second tab and a lost response. I tested an atomic claim, two kinds of grace window and coordination across tabs.
My worker pool cut median /ping from 1.8 s to 0.5 ms under load. The batch benchmark missed that and hid a bug in how I split the work.
I tested five old indexing rules on PostgreSQL 18.6 with EXPLAIN and BUFFERS. The plans changed how I choose and read indexes.
On PostgreSQL 16, Repeatable Read blocks phantoms but allows write skew. I checked both with two overlapping transactions.
A test sold 200 orders against 100 shirts. I measured which PostgreSQL updates prevent overselling and why a queue still needs idempotency.
A polling sync counted both versions of a corrected order. I keyed the projection by source identity and checked it against the source.
A missing await on run_in_executor left a loader reading old data. Await the jobs and publish the new state only after all succeed.
Shopee’s auth calls use a different signing string. The integration also has to coordinate refreshes per shop and handle seller reauthorization.
If a webhook signature fails after JSON parsing, check the raw request bytes before changing the signing key.