Chris van Eijk: Invoice numbers per tenant in PostgreSQL, without gaps

Sequence, max()+1, SERIALIZABLE or a counter row: five ways to number invoices per tenant, measured under load in PostgreSQL 17 for duplicates, gaps and speed.

cloud

Sources