From 59e9867a3090cb7f427a98de13d10269dcd79039 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Tue, 27 Jun 2017 14:54:46 +0200 Subject: [PATCH] Bug 18861 - branch_transfer_limits needs keys The branch transfers limits are edited in : /cgi-bin/koha/admin/branch_transfer_limits.pl This page calls a loop on IsBranchTransferAllowed with all destination branches and codes (ccodes or itemtypes). This can takes a huge time because table branch_transfer_limits has no keys. Since ccode or itemtype may be used, this patch adds a key on both combinaison : ccode/fromBranch/toBranch and itemtype/fromBranch/toBranch. Tested on a table with 66000 entries, time whent from 26 second to less than 1 second. Test plan : - Go to Administration > Library transfer limits - Check page load is faster - Uncheck a checkbox - Save => Verify save is OK - Change branch and same tests --- installer/data/mysql/atomicupdate/bug_18861.sql | 2 ++ installer/data/mysql/kohastructure.sql | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_18861.sql diff --git a/installer/data/mysql/atomicupdate/bug_18861.sql b/installer/data/mysql/atomicupdate/bug_18861.sql new file mode 100644 index 0000000..6f17c67 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_18861.sql @@ -0,0 +1,2 @@ +ALTER TABLE branch_transfer_limits ADD KEY `itemtype_idx` (`itemtype`,`fromBranch`,`toBranch`); +ALTER TABLE branch_transfer_limits ADD KEY `ccode_idx` (`ccode`,`fromBranch`, `toBranch`); diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index e9c60aa..4064fe4 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2667,7 +2667,9 @@ CREATE TABLE branch_transfer_limits ( fromBranch varchar(10) NOT NULL, itemtype varchar(10) NULL, ccode varchar(10) NULL, - PRIMARY KEY (limitId) + PRIMARY KEY (limitId), + KEY `itemtype_idx` (`itemtype`,`fromBranch`,`toBranch`), + KEY `ccode_idx` (`ccode`,`fromBranch`, `toBranch`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- 2.7.4