Skip to content

Don't fire referential integrity triggers if primary or unique keys haven't changed #8598

@gsbelarus

Description

@gsbelarus

We encountered the following issue on a large database:

#8593

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.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions