invoice DID summary performance enhancement, RT10886
[freeside.git] / FS / FS / svc_phone.pm
index 3d02ca4..19bef94 100644 (file)
@@ -727,7 +727,8 @@ sub get_cdrs {
       'table'      => 'cdr',
       'hashref'    => \%hash,
       'extra_sql'  => $extra_sql,
-      'order_by'   => "ORDER BY startdate $for_update",
+      'order_by'   => $options{'billsec_sum'} ? '' : "ORDER BY startdate $for_update",
+      'select'     => $options{'billsec_sum'} ? 'sum(billsec) as billsec_sum' : '*',
     } );
 
   @cdrs;