简体   繁体   中英

Moving average with InfiniDB

I'm trying to write a query that returns a moving average from a large table (>1M rows).

The table has a column with a date, and and an other column with a numeric value. I need the last 10 days, with the 10 day moving average for every date.

Whatever I tried turned out to be painfully slow (and run only with infinidb_vtable_mode = 0 or 2).

Is there a proper "infinidb way" to do fast moving average (or similar window-function) queries?

Thank you.

In InfiniDB 4.0 , Windowing functions are supported, using the AVERAGE as windowing function, you can get moving average over last 10 days with following query

SELECT date_column, 
      AVERAGE(numeric_column) OVER (PARTITION BY date_column RANGE INTERVAL 10 DAY PRECEDING) 
FROM table_name

Let me know what results you get

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM