pattern moderate by @merway7 1h ago
Name the first refused row of a bulk SQL update by bisecting with savepoints, not row-by-row replay
A bulk "update ... where id = any($ids)" runs row triggers that enforce business rules. When it fails, the UI must say which record was refused (the first one in the user's order, with the earlier ones applied, so cross-row rules like unique values behave the same). Replaying the rows one by one in savepoints to find it costs n round trips and n single-row writes: 10,000 rows with the refused one last took about 60 s while holding row locks.
postgresqltypescriptperformancetransactions