Bug 2898 - C4::Letters::parseletter kills performance in notice jobs
Summary: C4::Letters::parseletter kills performance in notice jobs
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Notices (show other bugs)
Version: Main
Hardware: PC All
: P3 normal
Assignee: Bugs List
QA Contact:
URL:
Keywords:
Depends on:
Blocks: 7923
  Show dependency treegraph
 
Reported: 2009-01-06 02:03 UTC by Chris Cormack
Modified: 2015-12-03 22:00 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Cormack 2010-05-21 00:57:43 UTC


---- Reported by joe.atzberger@liblime.com 2009-01-06 14:03:11 ----

parseletter() gets called 4 times for each non-digest notice.

Each call does one "show columns..." and one query from the following:

    if ( $table eq 'biblio' ) {
        $sth = $dbh->prepare("select * from biblio where biblionumber=?");
    } elsif ( $table eq 'biblioitems' ) {
        $sth = $dbh->prepare("select * from biblioitems where biblionumber=?");
    } elsif ( $table eq 'items' ) {
        $sth = $dbh->prepare("select * from items where itemnumber=?");
    } elsif ( $table eq 'reserves' ) {
        $sth = $dbh->prepare("select * from reserves where borrowernumber = ? and biblionumber=?");
    } elsif ( $table eq 'borrowers' ) {
        $sth = $dbh->prepare("select * from borrowers where borrowernumber=?");
    } elsif ( $table eq 'branches' ) {
        $sth = $dbh->prepare("select * from branches where branchcode=?");
    } elsif ( $table eq 'aqbooksellers' ) {
        $sth = $dbh->prepare("select * from aqbooksellers where id=?");
    }

At the very least, the show columns call should be cached in a hash by tablename.  They will not be changing at runtime.  

Also, the biblio SELECT queries should be more, um... selective and not pull the large marc and marxml fields, which would not be useful to notice jobs anyway.  

An else clause should be added to the end of the block above to explicitly die if some *other* tablename is referenced, since the job is about to die anyway when it goes to execute an unprepared $sth.  

Overall, some other process for getting most of this information should be considered.  It is really unnecessary to go requery each table individually 4 times for each pending notice when the same data could be retrieved at the outset from a properly JOINed query.



--- Bug imported by chris@bigballofwax.co.nz 2010-05-21 00:57 UTC  ---

This bug was previously known as _bug_ 2898 at http://bugs.koha.org/cgi-bin/bugzilla3/show_bug.cgi?id=2898

Actual time not defined. Setting to 0.0
The original reporter of this bug does not have
   an account here. Reassigning to the person who moved
   it here: chris@bigballofwax.co.nz.
   Previous reporter was joe.atzberger@liblime.com.

Comment 1 Jonathan Druart 2013-11-21 15:35:19 UTC
Not sure it is still valid: I don't find the "show columns" queries in C4::Letters.
Comment 2 Jonathan Druart 2015-03-17 11:39:05 UTC
Closing, please reopen if I am wrong.