Show
Ignore:
Timestamp:
10/24/09 16:10:24 (4 years ago)
Author:
Robert Treat <robert@omniti.com>
git-committer:
Robert Treat <robert@omniti.com> 1256400624 +0000
git-parent:

[8699626469587fd137436a5d6e40ed31ed2fef8f]

git-author:
Robert Treat <robert@omniti.com> 1256400624 +0000
Message:

make generic rollup function also handle 5m case

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sql/sprocs/stratcon.rollup_metric_numeric.sql

    rbf69392 r6985428  
    1919    v_count         INTEGER; 
    2020BEGIN 
    21     IF in_roll = '5m' THEN 
    22         PERFORM stratcon.rollup_metric_numeric_5m(); 
    23         RETURN 0; 
    24     END IF; 
    2521 
    2622    -- Get rollup config based on given name, and fail if its wrong name. 
     
    4541 
    4642    LOOP 
    47         IF v_i > 10 THEN 
     43        IF v_i > 12 THEN 
    4844            RETURN 1; 
    4945        END IF; 
     
    7066        END LOOP; 
    7167 
    72         v_sql := 'SELECT sid, name, $1 as rollup_time, SUM(1) as count_rows, (SUM(avg_value*1)/SUM(1)) as avg_value, (SUM(counter_dev*1)/SUM(1)) as counter_dev 
    73                   FROM  stratcon.unroll_metric_numeric( $1, $2, $3) 
    74                   GROUP BY sid, name'; 
    75 RAISE NOTICE 'v_sql was (%), %, %, %',v_sql,v_min_whence, v_min_whence + (v_conf.seconds - 1) * '1 second'::interval, v_conf.dependent_on;  
    76         FOR v_rec IN EXECUTE v_sql USING v_min_whence, 
    77                                          v_min_whence + (v_conf.seconds - 1) * '1 second'::interval, 
    78                                          v_conf.dependent_on LOOP 
     68        IF in_rollup = '5m' THEN 
     69            v_sql := 'SELECT * FROM stratcon.window_robust_derive('||quote_literal(v_min_whence)||')'; 
     70        ELSE 
     71            v_sql := 'SELECT sid, name, '||quote_literal(v_min_whence)||' as rollup_time, SUM(1) as count_rows, (SUM(avg_value*1)/SUM(1)) as avg_value,'; 
     72            v_sql := v_sql || ' (SUM(counter_dev*1)/SUM(1)) as counter_dev FROM stratcon.unroll_metric_numeric('||quote_literal(v_min_whence)||','; 
     73            v_sql := v_sql || quote_literal(v_min_whence + (v_conf.seconds - 1) * '1 second'::interval) || ',' || quote_literal(v_conf.dependent_on) ||')'; 
     74            v_sql := v_sql || ' GROUP BY sid, name';   
     75 
     76       --   v_sql := 'SELECT sid, name, $1 as rollup_time, SUM(1) as count_rows, (SUM(avg_value*1)/SUM(1)) as avg_value, (SUM(counter_dev*1)/SUM(1)) as counter_dev 
     77       --             FROM  stratcon.unroll_metric_numeric( $1, $2, $3) 
     78       --             GROUP BY sid, name'; 
     79        END IF; 
     80RAISE NOTICE 'v_sql was (%),v_sql;  
     81 
     82        FOR v_rec IN EXECUTE v_sql LOOP  
    7983            v_stored_rollup := floor( extract('epoch' from v_rec.rollup_time) / v_conf.span ) * v_conf.span; 
    8084            v_stored_rollup_tm := 'epoch'::timestamptz + v_stored_rollup * '1 second'::interval;