summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2013-03-13 14:49:56 -0700
committerIvan Kohler <ivan@freeside.biz>2013-03-13 14:49:56 -0700
commitc44e4e574c9268eae9213f95abc08471c45b48d0 (patch)
treeafdb271e74a22b56faf224b931c4a949ceb04007
parent7e90fee50d691a93369b1693cbb3743e627bdb03 (diff)
optimize line item detail "Paid" column inefficiency sometimes causing load issues for big installs, RT#21933
-rw-r--r--httemplate/search/cust_bill_pkg.cgi11
1 files changed, 5 insertions, 6 deletions
diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi
index 11937b3d5..70b460d3c 100644
--- a/httemplate/search/cust_bill_pkg.cgi
+++ b/httemplate/search/cust_bill_pkg.cgi
@@ -559,12 +559,11 @@ if ( $cgi->param('nottax') ) {
#total payments
-my $pay_sub = "SELECT SUM(cust_bill_pay_pkg.amount) AS pay_amount,
- billpkgnum
- FROM cust_bill_pay_pkg
- GROUP BY billpkgnum";
-$join_pkg .= " LEFT JOIN ($pay_sub) AS item_pay USING (billpkgnum)";
-push @select, 'item_pay.pay_amount';
+my $pay_sub = "SELECT SUM(cust_bill_pay_pkg.amount)
+ FROM cust_bill_pay_pkg
+ WHERE cust_bill_pkg.billpkgnum = cust_bill_pay_pkg.billpkgnum
+ ";
+push @select, "($pay_sub) AS pay_amount";
# credit