diff options
| author | Ivan Kohler <ivan@freeside.biz> | 2013-03-13 15:54:50 -0700 |
|---|---|---|
| committer | Ivan Kohler <ivan@freeside.biz> | 2013-03-13 15:54:50 -0700 |
| commit | 55bea78010c7ce83909202773e746f5a33852b45 (patch) | |
| tree | 03dd3ceab12f56871f54f93eb91510b2c0819a73 | |
| parent | 9a4f4f3eb604881f976546566efc671ffe65fdf2 (diff) | |
optimize line item detail "Credited" column inefficiency sometimes causing load issues for big installs, RT#21933
| -rw-r--r-- | httemplate/search/cust_bill_pkg.cgi | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi index c421711a5..48eb96c73 100644 --- a/httemplate/search/cust_bill_pkg.cgi +++ b/httemplate/search/cust_bill_pkg.cgi @@ -684,12 +684,12 @@ my $pay_sub = "SELECT SUM(cust_bill_pay_pkg.amount) push @select, "($pay_sub) AS pay_amount"; #total credits -my $credit_sub = "SELECT SUM(cust_credit_bill_pkg.amount) AS credit_amount, - billpkgnum - FROM cust_credit_bill_pkg - GROUP BY billpkgnum"; -$join_pkg .= " LEFT JOIN ($credit_sub) AS item_credit USING (billpkgnum)"; -push @select, 'item_credit.credit_amount'; +my $credit_sub = " + SELECT SUM(cust_credit_bill_pkg.amount) + FROM cust_credit_bill_pkg + WHERE cust_bill_pkg.billpkgnum = cust_credit_bill_pkg.billpkgnum +"; +push @select, "($credit_sub) AS credit_amount"; my $where = ' WHERE '. join(' AND ', @where); |
