Nightly bulk load into a table carrying an audit trigger takes four hours, and the trigger firing per row is the suspect. I want it off during the load and back on after.
What is the syntax and what should the job script guard against?
Nightly bulk load into a table carrying an audit trigger takes four hours, and the trigger firing per row is the suspect. I want it off during the load and back on after.
What is the syntax and what should the job script guard against?
Right suspect, common pattern. The syntax is one line each way with two guards that separate a solid job from a future incident.
The audit gap during the load is a real design decision rather than a detail: rows inserted while the trigger sleeps have no audit rows. If the audit matters for loaded data too, have the load itself write the audit entries in bulk afterwards, one INSERT from the loaded set into the audit table costs almost nothing compared to per row firing.
Load dropped from four hours to 40 minutes with the trigger off. The CATCH block enable saved us in week two exactly as predicted, the load failed and the trigger still came back on. Bulk audit backfill added as the final step.