Varlena, LLC | PostgreSQL General Bits Newsletter: "Turn off triggers for bulk load
[GENERAL] Turning off triggers ? 25-Nov-02
Another issue with bulk loading is triggers firing with each row inserted. If you are sure your data is trustworthy and already meets your referential integrity requirements, you can turn off triggers for the bulk load and turn them back on immediately afterward. You should not use this option when your data is not completely clean.
The reltriggers field in the pg_class table contains the number of triggers active for each table. It can be set to 0 the disable the triggers, but will need to be reset to the proper number of triggers to have them re-enabled.
UPDATE 'pg_class' SET 'reltriggers' = 0 WHERE 'relname' = 'tablename';
UPDATE pg_class SET reltriggers = (
SELECT count(*) FROM pg_trigger where pg_class.oid = tgrelid)
WHERE relname = 'table name';
Contributors: Glen Eustace geustace at godzone.net.nz, Stephan Szabo"
Thursday, December 07, 2006
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment