Koha/C4/Members.pm currently loads by itself Koha::Schema using "use Koha::Schema" even though this is not required as we could use Koha::Database that has already done that (another further issue is why does Koha::Database load all the classes in Koha/Schema/Result/ when it could just load the ones that are needed). Loading the Koha::Schema takes for me around 2 seconds on my machine so it would be quite a big performance boost to remove it. I got a 30% faster load time on cgi-bin/koha/members/moremember.pl with a patch I made. I will attach it here but be warned: I have not run any tests and I don't know if it has even syntax errors because I'm doing the patch on a machine without a proper development environment.
Created attachment 76556 [details] [review] Bug 21015: fix performance issue with C4::Members This is the proposed patch but please run the tests as I have not done so (yet).
Hi, this is already looking good. Could you still add a little test plan to see where the routine is used for the testers?
*** Bug 21160 has been marked as a duplicate of this bug. ***
Created attachment 80751 [details] [review] Bug 21015: fix performance issue with C4::Members loading Koha::Schema ("use Koha::Schema;") takes significantly time as it loads almost a couple hundred classes. Koha::Database has done that already once and we can use it to get the ResultSet "Borrower" as well, so let's use that. This also make the code more unified because Koha::Database is used throughout the code instead of Koha::Schema. Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Created attachment 80752 [details] [review] Bug 21015: Remove unecessary 'use Koha::Schema' statements in t/ Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
ho, excellent! % more t.pl use C4::Members; print get_cardnumber_length(); Without the patch: ~1.6s With the patch: 0.8s
Awesome! I should've looked more thoroughly when I reported #21160. This should have some nice knock on effects, especially for CGI users.
Created attachment 81865 [details] [review] Bug 21015: fix performance issue with C4::Members loading Koha::Schema ("use Koha::Schema;") takes significantly time as it loads almost a couple hundred classes. Koha::Database has done that already once and we can use it to get the ResultSet "Borrower" as well, so let's use that. This also make the code more unified because Koha::Database is used throughout the code instead of Koha::Schema. Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Created attachment 81866 [details] [review] Bug 21015: Remove unecessary 'use Koha::Schema' statements in t/ Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Awesome work all! Pushed to master for 18.11
Pushed to 18.05.x for 18.05.06
Pushed to 17.11.x for 17.11.13