diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-05-10 23:53:48 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-05-10 23:53:48 +0000 |
commit | 9f2e4f8aa506dd02926398fb9c474ec297567872 (patch) | |
tree | 00bb0b370ba3ee2185b82d84168d711ba5235949 | |
parent | bd57057f2d8b64ded0969ec9029c84b15e997c53 (diff) |
Adding performance patch for larger datasets
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/branches/1.2@1180 4979c152-3d1c-0410-bac9-87ea11338e46
-rw-r--r-- | Changelog | 1 | ||||
-rwxr-xr-x | LedgerSMB/Form.pm | 24 |
2 files changed, 6 insertions, 19 deletions
@@ -11,6 +11,7 @@ Changelog for 1.2.5 * Corrected number parsing issues with 1.000,00 formats (Chris T). * Corrected a number of date handling issues and added tests (Seneca). * Applied invoice performance patch from Ashley Gittins (Chris T) +* Applide performance improvements to lastname_used (Chris T) Changelog for 1.2.4 * Fixed internal functions avgcost() and lastcost() to not use float (Joshua D) diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm index dafeff19..8cc59544 100755 --- a/LedgerSMB/Form.pm +++ b/LedgerSMB/Form.pm @@ -2408,29 +2408,15 @@ sub lastname_used { } my $query = qq| - SELECT id - FROM $arap - WHERE id IN - (SELECT MAX(id) - FROM $arap - WHERE $where AND ${vc}_id > 0)|; - - my ($trans_id) = $dbh->selectrow_array($query); - - $trans_id *= 1; - - $query = qq| - SELECT ct.name AS $vc, a.curr AS currency, a.${vc}_id, + SELECT ct.name AS $vc, ct.curr AS currency, ct.id AS ${vc}_id, current_date + ct.terms AS duedate, - a.department_id, d.description AS department, ct.notes, + ct.notes, ct.curr AS currency - FROM $arap a - JOIN $vc ct ON (a.${vc}_id = ct.id) - LEFT JOIN department d ON (a.department_id = d.id) - WHERE a.id = ?|; + FROM $vc ct + WHERE ct.id = (select customer_id from $arap where $where AND ${vc}_id IS NOT NULL order by id DESC limit 1)|; $sth = $dbh->prepare($query); - $sth->execute($trans_id) || $self->dberror($query); + $sth->execute() || $self->dberror($query); my $ref = $sth->fetchrow_hashref(NAME_lc); for ( keys %$ref ) { $self->{$_} = $ref->{$_} } |