Show
Ignore:
Timestamp:
03/28/08 19:38:56 (6 years ago)
Author:
Denish Patel <denish@omniti.com>
git-committer:
Denish Patel <denish@omniti.com> 1206733136 +0000
git-parent:

[5eaa1785247692fe06e4dffe28ec8abdf751865a]

git-author:
Denish Patel <denish@omniti.com> 1206733136 +0000
Message:

Final 5 minutes and 1 hour rollup functions

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sql/schema.sql

    r5eaa178 ree0d0b7  
    210210 v_max_rollup_5 TIMESTAMPTZ; 
    211211 v_whence TIMESTAMPTZ; 
     212 rows INT; 
    212213  
    213214BEGIN 
     
    219220         INTO v_max_rollup_5;         
    220221  
    221  IF v_min_whence < v_max_rollup_5 THEN 
     222 -- Insert Log for Hourly rollup 
     223    
     224   SELECT whence FROM stratcon.log_whence_s WHERE whence=date_trunc('H',v_min_whence) and interval='1 hour' 
     225           INTO v_whence; 
     226      IF NOT FOUND THEN 
     227       INSERT INTO  stratcon.log_whence_s VALUES(date_trunc('H',v_min_whence),'1 hour'); 
     228   END IF; 
     229    
     230 IF v_min_whence <= v_max_rollup_5 THEN 
    222231 
    223232   DELETE FROM stratcon.rollup_matrix_numeric_5m  
    224233                WHERE rollup_time = v_min_whence; 
    225    
    226   ELSIF  v_min_whence = v_max_rollup_5 THEN 
    227   
    228   DELETE FROM stratcon.log_whence_s  
    229         WHERE WHENCE=v_min_whence AND INTERVAL='5 minutes'; 
    230          
    231     RETURN;         
    232  
     234  
    233235 END IF; 
    234236 
     
    242244       LOOP 
    243245     
     246         
    244247        INSERT INTO stratcon.rollup_matrix_numeric_5m 
    245248         (sid,name,rollup_time,count_rows,avg_value,stddev_value,min_value,max_value) VALUES  
     
    248251   END LOOP; 
    249252 
    250   -- Insert Log for Hourly rollup 
    251    
    252   SELECT whence FROM stratcon.log_whence_s WHERE whence=date_trunc('H',v_min_whence) and interval='1 hour' 
    253           INTO v_whence; 
    254      IF NOT FOUND THEN 
    255       INSERT INTO  stratcon.log_whence_s VALUES(date_trunc('H',v_min_whence),'1 hour'); 
    256    END IF; 
    257     
    258     
    259253  -- Delete from whence log table 
    260254   
     
    270264END 
    271265$$ LANGUAGE plpgsql; 
    272  
    273266-- 1 hourl rollup 
    274267