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,
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,
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,
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,
--- /dev/null
+-- 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);