summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorivan <ivan>2011-05-19 15:51:50 +0000
committerivan <ivan>2011-05-19 15:51:50 +0000
commit144668a01beef406a027c78bc2883e111e621cc2 (patch)
tree1036c18349de87efd8fae1ab2eafca4a8cea1387 /FS
parent636f7647b10e49d62d0b5244b8a233ed46a8630a (diff)
optimize torrus-srvderive, RT#10574
Diffstat (limited to 'FS')
-rw-r--r--FS/bin/freeside-torrus-srvderive15
1 files changed, 9 insertions, 6 deletions
diff --git a/FS/bin/freeside-torrus-srvderive b/FS/bin/freeside-torrus-srvderive
index 80f222b1c..525d6ceb5 100644
--- a/FS/bin/freeside-torrus-srvderive
+++ b/FS/bin/freeside-torrus-srvderive
@@ -60,8 +60,8 @@ my $sql = "
my $orderlimit = "
ORDER BY srv_date, srv_time
- LIMIT 100
-"; #50?
+ LIMIT 50
+";
if ( driver_name eq 'mysql' ) {
dbh->do('SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED');
@@ -195,9 +195,12 @@ while (1) {
my $sin = join(',', map dbh->quote("$_$dir"), @serviceids);
+ my $srv_date = time2str('%Y-%m-%d', $cur);
+
my $sum = "
SELECT COALESCE(SUM(value),0) FROM srvexport AS other
WHERE other.serviceid IN ($sin)
+ AND other.srv_date = '$srv_date'
AND ABS( $cur - $other_date ) <= 60
";
@@ -205,10 +208,10 @@ while (1) {
INSERT INTO srvexport ( srv_date, srv_time, serviceid, value, intvl )
VALUES ( ?, ?, ?, ($sum), ? )
";
- my @param = ( time2str('%Y-%m-%d', $cur), #srv_date
- time2str('%X', $cur), #srv_time
- "$serviceid$dir",
- 300, #intvl ...
+ my @param = ( $srv_date,
+ time2str('%X', $cur), #srv_time
+ "$serviceid$dir", #serviceid
+ 300, #intvl ...
);
warn $isql. ' with param '. join(',',@param). "\n"
if $DEBUG > 2;