ShelfBrowser uses two SQL queries with syntax

WHERE ((cn_sort = ? AND itemnumber < ?) OR cn_sort < ?)
AND homebranch = ? AND location = ? AND ccode = ?

homebranch already has index, and adding indexes on ccode and location
improves performance by 30% for each query since MySQL is able to use
index_merge intersect(items_ccode,homebranch,items_location)
---
 installer/data/mysql/updatedatabase.pl |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/installer/data/mysql/updatedatabase.pl 
b/installer/data/mysql/updatedatabase.pl
index 503c8ee..f546136 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -5146,6 +5146,14 @@ if ( C4::Context->preference("Version") < 
TransformToNum($DBversion) ) {
     SetVersion($DBversion);
 }
 
+$DBversion = "3.07.00.XXX";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+    $dbh->do("CREATE INDEX items_location ON items(location)");
+    $dbh->do("CREATE INDEX items_ccode ON items(ccode)");
+    print "Upgrade to $DBversion done (items_location and items_ccode indexes 
added for ShelfBrowser)";
+    SetVersion($DBversion);
+}
+
 =head1 FUNCTIONS
 
 =head2 DropAllForeignKeys($table)
-- 
1.7.2.5

_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to