From: Dan Scott Date: Sat, 7 Jan 2012 21:31:38 +0000 (-0500) Subject: Speed up 'archive stat cats' database upgrade X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fdbs%2Fspeedier_0663_upgrade;p=working%2FEvergreen.git Speed up 'archive stat cats' database upgrade The action.circulation table has four triggers that fire on UPDATE events, and the 0663 database upgrade issues two updates that affect every row in that table - which can take a long time to complete on systems with relatively active circulation systems. We can speed things up somewhat by preventing the triggers from firing during the update. Signed-off-by: Dan Scott --- diff --git a/Open-ILS/src/sql/Pg/upgrade/0663.schema.archive_circ_stat_cats.sql b/Open-ILS/src/sql/Pg/upgrade/0663.schema.archive_circ_stat_cats.sql index 022b2ddd70..915a9d01a8 100644 --- a/Open-ILS/src/sql/Pg/upgrade/0663.schema.archive_circ_stat_cats.sql +++ b/Open-ILS/src/sql/Pg/upgrade/0663.schema.archive_circ_stat_cats.sql @@ -32,6 +32,9 @@ ALTER TABLE actor.stat_cat ALTER TABLE asset.stat_cat ADD COLUMN checkout_archive BOOL NOT NULL DEFAULT FALSE; +-- Speed up the upgrade process prevening the four UPDATE triggers from firing +ALTER TABLE action.circulation DISABLE TRIGGER ALL; + -- Circulation copy column ALTER TABLE action.circulation ADD COLUMN copy_location INT NOT NULL DEFAULT 1 REFERENCES asset.copy_location(id) DEFERRABLE INITIALLY DEFERRED; @@ -39,6 +42,9 @@ ALTER TABLE action.circulation -- Update action.circulation with real copy_location numbers instead of all "Stacks" UPDATE action.circulation circ SET copy_location = ac.location FROM asset.copy ac WHERE ac.id = circ.target_copy; +-- Re-enable the triggers now that the upgrade of the table is complete +ALTER TABLE action.circulation ENABLE TRIGGER ALL; + -- Create trigger function to auto-fill the copy_location field CREATE OR REPLACE FUNCTION action.fill_circ_copy_location () RETURNS TRIGGER AS $$ BEGIN