Hi,
I have found myself in a situation where I need to quickly delete rows
from a production database. Unfortunately table for the rows to be
deleted have triggers which results massive chain of update operations
on other tables. I do not wish those to happen as I'm about to delete
concerned rows from the other tables as well. (7.4.7)
Would
begin work
select reltriggers from pg_class where relname='foo' for update;
update pg_class set reltriggers=0 where relname='foo';
delete from foo where ...
update pg_class set reltriggers=original value where relname='foo';
commit
work?
Or
begin work
select reltriggers from pg_class where relname='foo';
update pg_class set reltriggers=0 where relname='foo';
delete from foo where ...
update pg_class set reltriggers=original value where relname='foo';
commit
as I'm quite sure the number of triggers for that table will not change
while I'm doing the deletion.
Thank you.