LP#1615736 - Add an index on the usr field of action.usr_circ_history.
authorJosh Stompro <stomproj@larl.org>
Mon, 29 Aug 2016 19:07:48 +0000 (14:07 -0500)
committerGalen Charlton <gmc@esilibrary.com>
Wed, 16 Nov 2016 16:44:18 +0000 (11:44 -0500)
Improve the performance of looking up a users circ history by adding
an index on action.usr_circ_history( usr ).

To test for performance improvements time doing a search for a particular
users history before and after the index is created.

Signed-off-by: Josh Stompro <stomproj@larl.org>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/src/sql/Pg/090.schema.action.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.action_usr_circ_history_index.sql [new file with mode: 0644]

index 731ab3c..19e1f1e 100644 (file)
@@ -1412,6 +1412,8 @@ CREATE TABLE action.usr_circ_history (
                  ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED
 );
 
+CREATE INDEX action_usr_circ_history_usr_idx ON action.usr_circ_history ( usr );
+
 CREATE TRIGGER action_usr_circ_history_target_copy_trig 
     AFTER INSERT OR UPDATE ON action.usr_circ_history 
     FOR EACH ROW EXECUTE PROCEDURE evergreen.fake_fkey_tgr('target_copy');
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.action_usr_circ_history_index.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.action_usr_circ_history_index.sql
new file mode 100644 (file)
index 0000000..965d983
--- /dev/null
@@ -0,0 +1,7 @@
+BEGIN;
+
+-- SELECT evergreen.upgrade_deps_block_check('xxxx', :eg_version);
+
+CREATE INDEX action_usr_circ_history_usr_idx ON action.usr_circ_history ( usr );
+
+COMMIT;