summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-05-10 23:53:09 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-05-10 23:53:09 +0000
commit24c70e444b6c8017ce240e5ad6f1cae8368cc240 (patch)
tree4c609cdd789fd7b3f56df884a50abad2855535c1
parent07e40330c01733801faabd332ae0db3bad7b707b (diff)
Adding performance patch for larger datasets
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1179 4979c152-3d1c-0410-bac9-87ea11338e46
-rw-r--r--LedgerSMB/Form.pm24
1 files changed, 5 insertions, 19 deletions
diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm
index b8a23b01..6eba7223 100644
--- a/LedgerSMB/Form.pm
+++ b/LedgerSMB/Form.pm
@@ -2403,29 +2403,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->{$_} }