Here's a table definition you've probably written, approved in review, or copied from a tutorial:
CREATE TABLE orders ( id uuid PRIMARY KEY DEFAULT gen_random_uuid ( ) , customer_id uuid NOT NULL , total_cents bigint NOT NULL , created_at timestamptz NOT NULL DEFAULT now ( ) ) ;
Enter fullscreen mode
Exit fullscreen mode
Nothing is wrong with it on day one. IDs are unguessable, you can generate them on any service without a round trip, and merging data from two databases never collides. It works fine at ten thousand rows. It works fine at a million.
Then the table outgrows memory, and that DEFAULT gen_random_uuid() starts costing you in a way that doesn't show up in any single query plan. Every insert lands on a random page of the primary key index. Pages split in half and stay half empty. Checkpoints turn into a flood of full-page images in the WAL.…