From: dbs Date: Wed, 24 Nov 2010 03:31:14 +0000 (+0000) Subject: Add an index on asset.copy(create_date) for item-age browse X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e4c5617449cf817080f3f9872bb7d95845ae0174;p=evergreen%2Fbjwebb.git Add an index on asset.copy(create_date) for item-age browse Running an item-age browse against a database with a reasonable number of entries in asset.copy is dog-slow without an index like this. git-svn-id: svn://svn.open-ils.org/ILS/trunk@18842 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index d64150cfc..b2f36e925 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -70,7 +70,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0465'); -- dbs +INSERT INTO config.upgrade_log (version) VALUES ('0466'); -- dbs CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/040.schema.asset.sql b/Open-ILS/src/sql/Pg/040.schema.asset.sql index 767f46e9e..c453619f3 100644 --- a/Open-ILS/src/sql/Pg/040.schema.asset.sql +++ b/Open-ILS/src/sql/Pg/040.schema.asset.sql @@ -88,6 +88,7 @@ CREATE INDEX cp_cn_idx ON asset.copy (call_number); CREATE INDEX cp_avail_cn_idx ON asset.copy (call_number); CREATE INDEX cp_creator_idx ON asset.copy ( creator ); CREATE INDEX cp_editor_idx ON asset.copy ( editor ); +CREATE INDEX cp_create_date ON asset.copy (create_date); CREATE RULE protect_copy_delete AS ON DELETE TO asset.copy DO INSTEAD UPDATE asset.copy SET deleted = TRUE WHERE OLD.id = asset.copy.id; CREATE TABLE asset.opac_visible_copies ( diff --git a/Open-ILS/src/sql/Pg/upgrade/0466.schema.asset-copy-add-create-date-index.sql b/Open-ILS/src/sql/Pg/upgrade/0466.schema.asset-copy-add-create-date-index.sql new file mode 100644 index 000000000..813b215b6 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0466.schema.asset-copy-add-create-date-index.sql @@ -0,0 +1,8 @@ + +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0466'); -- dbs + +CREATE INDEX cp_create_date ON asset.copy (create_date); + +COMMIT;