From ae452c4f4e434e27a947a040834344477dc9257b Mon Sep 17 00:00:00 2001 From: dbs Date: Wed, 18 Aug 2010 02:09:17 +0000 Subject: [PATCH] Create indexes on some Vandelay tables to speed up retrieval and delete operations git-svn-id: svn://svn.open-ils.org/ILS/trunk@17236 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/012.schema.vandelay.sql | 4 ++++ .../src/sql/Pg/upgrade/0374.schema.vandelay_indices.sql | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0374.schema.vandelay_indices.sql diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 3106a8e8c..66c947c37 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -68,7 +68,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0373'); -- phasefx +INSERT INTO config.upgrade_log (version) VALUES ('0374'); -- dbs CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/012.schema.vandelay.sql b/Open-ILS/src/sql/Pg/012.schema.vandelay.sql index 5a8af42c3..41372e237 100644 --- a/Open-ILS/src/sql/Pg/012.schema.vandelay.sql +++ b/Open-ILS/src/sql/Pg/012.schema.vandelay.sql @@ -80,6 +80,7 @@ CREATE TABLE vandelay.queued_bib_record ( imported_as INT REFERENCES biblio.record_entry (id) DEFERRABLE INITIALLY DEFERRED ) INHERITS (vandelay.queued_record); ALTER TABLE vandelay.queued_bib_record ADD PRIMARY KEY (id); +CREATE INDEX queued_bib_record_queue_idx ON vandelay.queued_bib_record (queue); CREATE TABLE vandelay.queued_bib_record_attr ( id BIGSERIAL PRIMARY KEY, @@ -87,6 +88,7 @@ CREATE TABLE vandelay.queued_bib_record_attr ( field INT NOT NULL REFERENCES vandelay.bib_attr_definition (id) DEFERRABLE INITIALLY DEFERRED, attr_value TEXT NOT NULL ); +CREATE INDEX queued_bib_record_attr_record_idx ON vandelay.queued_bib_record_attr (record); CREATE TABLE vandelay.bib_match ( id BIGSERIAL PRIMARY KEY, @@ -1181,6 +1183,7 @@ CREATE TABLE vandelay.queued_authority_record ( imported_as INT REFERENCES authority.record_entry (id) DEFERRABLE INITIALLY DEFERRED ) INHERITS (vandelay.queued_record); ALTER TABLE vandelay.queued_authority_record ADD PRIMARY KEY (id); +CREATE INDEX queued_authority_record_queue_idx ON vandelay.queued_authority_record (queue); CREATE TABLE vandelay.queued_authority_record_attr ( id BIGSERIAL PRIMARY KEY, @@ -1188,6 +1191,7 @@ CREATE TABLE vandelay.queued_authority_record_attr ( field INT NOT NULL REFERENCES vandelay.authority_attr_definition (id) DEFERRABLE INITIALLY DEFERRED, attr_value TEXT NOT NULL ); +CREATE INDEX queued_authority_record_attr_record_idx ON vandelay.queued_authority_record_attr (record); CREATE TABLE vandelay.authority_match ( id BIGSERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/upgrade/0374.schema.vandelay_indices.sql b/Open-ILS/src/sql/Pg/upgrade/0374.schema.vandelay_indices.sql new file mode 100644 index 000000000..0665ffe5b --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0374.schema.vandelay_indices.sql @@ -0,0 +1,14 @@ +-- No transaction is required +INSERT INTO config.upgrade_log (version) VALUES ('0374'); -- dbs + +-- Triggers on the vandelay.queued_*_record tables delete entries from +-- the associated vandelay.queued_*_record_attr tables based on the record's +-- ID; create an index on that column to avoid sequential scans for each +-- queued record that is deleted +CREATE INDEX queued_bib_record_attr_record_idx ON vandelay.queued_bib_record_attr (record); +CREATE INDEX queued_authority_record_attr_record_idx ON vandelay.queued_authority_record_attr (record); + +-- Avoid sequential scans for queue retrieval operations by providing an +-- index on the queue column +CREATE INDEX queued_bib_record_queue_idx ON vandelay.queued_bib_record (queue); +CREATE INDEX queued_authority_record_queue_idx ON vandelay.queued_authority_record (queue); -- 2.11.0