Bug 15106

Summary: Batch Patron Modification Performance Improvement
Product: Koha Reporter: cnorthcott.work
Component: PatronsAssignee: cnorthcott.work
Status: Patch doesn't apply --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: gmcharlt, kyle.m.hall
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 7923    
Attachments: Bug 15106:: Batch Patron Modification Performance Improvement
CSV file containing patron data for import
Card Numbers txt file for identifying patrons to modify

Description cnorthcott.work 2015-11-02 00:49:49 UTC
Batch Patron Modification has a fairly long run/load time. I have attempted to improve the runtime of the Batch Patron Modification tool and my enhancement reduces the time to modify a batch of patrons by an average of 44.02%

I discovered the extended runtime was mostly due to detailed data retrieval in preparation for display. The overhead for a batch of 1000 patrons was enough that I have changed functionality so that if there are more than 20 patrons in the batch to simply display a success message instead of the details of every changed patron. There are other small code logic improvements also included to prevent unnecessary function calls.

In the end my test case of 1000 patrons originally took 59.02 seconds to modify, after optimisation it took 33.04 seconds saving 25.98 seconds.
Comment 1 cnorthcott.work 2015-11-05 23:58:24 UTC
Created attachment 44529 [details] [review]
Bug 15106:: Batch Patron Modification Performance Improvement

Batch Patron Modification has a fairly long run/load time. I have attempted
to improve the runtime of the Batch Patron Modification tool by removing
unecessary reporting detail after large batch patron changes and altering
some logic to avoid fetching and checking data that won't be needed.

Test Plan:
1) Prepare NTYprof (http://wiki.koha-community.org/wiki/Profiling_with_Devel::NYTProf)
   or procure a stopwatch (stopwatch will be simpler but less accurate).
2) Ensure you have a decent number of patrons in your Koha system (>500) if you are
   lacking patrons to modify in your database you can import 1000 using the
   PatronDataCSV.csv attachement and the Import Patrons tool before moving to
   step 3.
3) Prepare a file with the cardnumber of borrowers to modify. If you imported
   patrons using PatronDataCSV.csv you can use the attached PatronCardNums.txt
4) Navigate to Home > Tools > Batch Patrons Modification in the Koha Intranet.
5) Click the "Browse..." button and select PatronCardNums.txt
6) Click the "Continue" button and scroll to the bottom of the page.
7) Enter text into the "Country" field box.
8) Enter text into the "Circulation note" field box.
9) If you are using a stopwatch, prepare your stopwatch so that you will
   start counting seconds from the point you click the button in the next
   step.
10) Click the "Save" button (simultaneously start your stopwatch if using one)
11) When the page appears showing completion of the change, stop your stopwatch
    and check the time or navigate to the folder you have set NYTProf to output.
12) Record the runtime. This is the pre-optimisation time.
13) If this is your pre-patch test, the success page will show all the patrons
    with the data changed, if this is your post-patch test it should only show
    a "Successfully changed <number> patrons" message.
13) Apply this patch.
14) Repeat steps 2-12 of this testplan with the patch applied. This will yield
    the post-optimisation time.
15) Compare the pre-optimisation time and post optimisation time. The second
    post-optimisation time should be faster.
Comment 2 cnorthcott.work 2015-11-05 23:58:52 UTC
Created attachment 44530 [details]
CSV file containing patron data for import
Comment 3 cnorthcott.work 2015-11-06 00:01:35 UTC
Created attachment 44531 [details]
Card Numbers txt file for identifying patrons to modify