LP#1479953: Add indexes to vqbr foreign key references
authorJeff Davis <jdavis@sitka.bclibraries.ca>
Thu, 30 Jul 2015 20:12:35 +0000 (13:12 -0700)
committerJason Stephenson <jstephenson@mvlc.org>
Thu, 6 Aug 2015 15:44:26 +0000 (11:44 -0400)
Deleting a bib queue can be quite slow if it contains many queued
records.  This is because each queued record needs to be deleted, and
this in turn affects many tables that contain unindexed foreign key
references to vandelay.queued_bib_record.  Indexing those foreign keys
can speed up bib queue deletion substantially.

Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/src/sql/Pg/012.schema.vandelay.sql
Open-ILS/src/sql/Pg/200.schema.acq.sql
Open-ILS/src/sql/Pg/201.acq.audit-functions.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.index.queued_record.sql [new file with mode: 0644]

index b86eda1..25e1a6d 100644 (file)
@@ -150,6 +150,7 @@ CREATE TABLE vandelay.bib_match (
     quality         INT         NOT NULL DEFAULT 1,
     match_score     INT         NOT NULL DEFAULT 0
 );
+CREATE INDEX bib_match_queued_record ON vandelay.bib_match (queued_record);
 
 CREATE TABLE vandelay.import_item (
     id              BIGSERIAL   PRIMARY KEY,
@@ -180,6 +181,7 @@ CREATE TABLE vandelay.import_item (
     opac_visible    BOOL,
     internal_id     BIGINT -- queue_type == 'acq' ? acq.lineitem_detail.id : asset.copy.id
 );
+CREATE INDEX import_item_record ON vandelay.import_item (record);
 
 CREATE TABLE vandelay.import_bib_trash_group(
     id           SERIAL  PRIMARY KEY,
index 91204a4..9c9f9e5 100644 (file)
@@ -489,6 +489,7 @@ CREATE INDEX li_pl_idx ON acq.lineitem (picklist);
 CREATE INDEX li_creator_idx   ON acq.lineitem ( creator );
 CREATE INDEX li_editor_idx    ON acq.lineitem ( editor );
 CREATE INDEX li_selector_idx  ON acq.lineitem ( selector );
+CREATE INDEX li_queued_record ON acq.lineitem ( queued_record );
 
 CREATE TABLE acq.lineitem_alert_text (
     id               SERIAL         PRIMARY KEY,
index 51f3507..383e29f 100644 (file)
@@ -103,5 +103,6 @@ CREATE INDEX acq_po_hist_id_idx            ON acq.acq_purchase_order_history( id
 
 SELECT acq.create_acq_auditor ( 'acq', 'lineitem' );
 CREATE INDEX acq_lineitem_hist_id_idx            ON acq.acq_lineitem_history( id );
+CREATE INDEX acq_lineitem_history_queued_record  ON acq.acq_lineitem_history (queued_record);
 
 COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.index.queued_record.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.index.queued_record.sql
new file mode 100644 (file)
index 0000000..4ca13c7
--- /dev/null
@@ -0,0 +1,15 @@
+BEGIN;
+
+/* LP#1479953: Adding indexes to foreign key references to
+ * vandelay.queued_bib_record will speed up deletions of vqbr records (thereby
+ * speeding up vandelay.bib_queue deletions).
+ */
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE INDEX acq_lineitem_history_queued_record ON acq.acq_lineitem_history (queued_record);
+CREATE INDEX li_queued_record ON acq.lineitem (queued_record);
+CREATE INDEX bib_match_queued_record ON vandelay.bib_match (queued_record);
+CREATE INDEX import_item_record ON vandelay.import_item (record);
+
+COMMIT;