article
One counter row, rewritten for every inserted row
An exact record total cost a full count on every first page, and the first trigger-maintained counter turned bulk inserts quadratic. Per-row deltas folded once per statement fixed it, with a strict rule for when the counter may answer and a lock timeout so adding the trigger can't freeze every writer.
Read more 3m read