UUIDv4 randomness turns your clustered index into a write bottleneck. Here is how UUIDv7 and ULID fix the insertion hotspot, with Node.js generation code, Postgres index analysis, and the one case where ULID still wins.
Two-phase commit is the textbook answer for distributed transactions. It also doesn't survive contact with real systems. The saga pattern — orchestrated or choreographed — is what production systems actually use. Here is the difference, the implementation patterns, and the compensation logic that handles the inevitable failure cases.
A 2 TB events table is hard to manage and impossible to clean. Time-based partitioning turns it into 30 small tables you can drop on a cron. Here is the working pattern with declarative partitioning, automated partition management, and the three traps that catch teams new to it.
The UUID-vs-bigint debate is religious in some teams and absent in others. The numbers behind it are surprisingly clean: random UUIDs cost 30%+ more disk and a measurable insert-time penalty, but UUID v7 (time-ordered) closes most of the gap. Here is the data, the patterns each fits, and the “use both” design that ends the argument.
Most TypeScript domain models are a single interface with twenty optional fields, half of which are mutually exclusive. Discriminated unions are the feature that turns that into the actual shape of the data — and lets the compiler narrow precisely. Here is the pattern, applied to four real domain shapes.
JSONB columns let you ship features without a migration, which is exactly why they end up holding half your domain model. Here is the rule for when JSONB is the right call, the four queries that decide whether to promote a key to a column, and the GIN-index pattern that keeps it fast.