[討論] query sampling data

作者: poc7667 (poc)   2014-12-08 13:01:59
原始資料
Timestamp High Low Volume
10:24.22345 100 99 10
10:24.23345 110 97 20
10:24.33455 97 89 40
10:25.33455 60 40 50
我可以對原始資料指定一段時間做 sampling 的動作
假設以一秒為單位
Timestamp High Low Volume Count
10:24 110 89 70 3
10:25 60 20 110 2
我開發的框架是 Ruby on Rails 資料庫是 PostgreSQL
我想請教這類型的較佳作法為何呢? 可以讓我縮短 query 的時間
這些動作我想可以輕易的在 Rails 上面的 model 或者 concern 做掉,
但是是否會造成效能嚴重低落?
因為我的想法是如果能在 database 處理應該就要放在 db 處理才是
這部份是否有相關的文章,或者方向可以指點呢?謝謝
我在 stackoverflow 上面的原文問題
How to do sampling on data on a query in a short time
Suppose my raw data is that
Timestamp High Low Volume
10:24.22345 100 99 10
10:24.23345 110 97 20
10:24.33455 97 89 40
10:25.33455 60 40 50
10:25.93455 40 20 60
If I sampling for 1 second,
The output data should be
Timestamp High Low Volume Count
10:24 110 89 70 3
10:25 60 20 110 2
The sampling unit from varing from `1 second, 5 sec, 1 minute, 1 hour, 1 day, ...`
How to query the sampled data in quick time in the postgreSQL database with Rails ?

Links booklink

Contact Us: admin [ a t ] ucptt.com