summaryrefslogtreecommitdiff
path: root/httemplate/search
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2013-03-13 15:56:35 -0700
committerIvan Kohler <ivan@freeside.biz>2013-03-13 15:56:35 -0700
commit65bead8e2353121c19cc55f9483f2662c9f3bb23 (patch)
treea2b52922a9a034151dc6e99cbe8e82e7287616f2 /httemplate/search
parentc44e4e574c9268eae9213f95abc08471c45b48d0 (diff)
optimize line item detail "Credited" column inefficiency sometimes causing load issues for big installs, RT#21933
Diffstat (limited to 'httemplate/search')
-rw-r--r--httemplate/search/cust_bill_pkg.cgi13
1 files changed, 6 insertions, 7 deletions
diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi
index 70b460d3c..0f51d9481 100644
--- a/httemplate/search/cust_bill_pkg.cgi
+++ b/httemplate/search/cust_bill_pkg.cgi
@@ -629,13 +629,12 @@ if ( $cgi->param('credit') ) {
#still want a credit total column
- 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";
}