A side effect of this command is that you take an exclusive lock on the table:
ALTER TABLE DISABLE trigger ALL;
The manual on the DISABLE TRIGGER
clause:
This command acquires a SHARE ROW EXCLUSIVE
lock.
About SHARE ROW EXCLUSIVE
:
[...] This mode protects a table against concurrent data changes, and
is self-exclusive so that only one session can hold it at a time.
This can prevent locking contention with concurrent transactions during the big DELETE
- which can explain the unreasonably long time you reported all by itself.
The effect is independent from any triggers on the table actually existing. But you do, in fact, have triggers. You mention foreign key tables, and FK constraints are implemented with special triggers internally. See:
Since you specified ALL
(as opposed to USER
) those are included.
The manual again:
One can disable or enable a single trigger specified by name, or all
triggers on the table, or only user triggers (this option excludes
internally generated constraint triggers such as those that are used
to implement foreign key constraints or deferrable uniqueness and
exclusion constraints).
Bold emphasis mine.
Disabling FK checks saves time, of course. (Especially if that triggers a cascade of additional triggers, under concurrent load ...) But it can also break referential integrity and functionality like CASCADE
options. So this is reserved to superusers and the manual warns against it. Be sure to read up.
Can't say which of the two effects contributed more.