On Tue, 25 Dec 2018 at 08:04, Dean Rasheed <dean.a.rash...@gmail.com> wrote: > Take a look at this code in AfterTriggerSaveEvent(): >
Note that the intention behind that code is that in the (fairly common) case where an insert or update operation is known to not lead to any potential PK/UNIQUE index violations, the overhead for the deferred recheck is minimal. For example, consider a bulk insert where IDs come from a sequence known to not overlap with existing IDs. In that case, each new ID is determined at index insertion time to not possibly conflict with any existing ID, recheckIndexes remains empty for each row, and no recheck triggers are ever queued. One of the tricky things about replacing the current rechecks with statement level triggers will be working out how to deal with such cases (or cases with just a tiny fraction of keys to be rechecked) without introducing a large overhead. Regards, Dean