Description
We encountered the following issue on a large database:
We needed to update a table containing 172 million records. The update did not modify the primary key of any records — it only updated three integer fields. However, since the table was referenced by 1,358 foreign keys, the operation triggered:
1.72 × 10⁸ × 1.358 × 10³ ≈ 10¹¹
system trigger calls. These trigger calls alone caused the update to take 19 hours.
The proposed solution is to skip referential integrity triggers when the primary key or any other unique key is not modified.