开发者

How can I calculate data for a boxplot (quartiles, median) in a Rails app on Heroku? (Heroku uses Postgresql)

I'm trying to calculate the data needed to generate a box plot which means I need to figure out the 1st and 3rd Quartiles along with the median. I have found some solutions for doing it in Postgresql however they seem to depend on either PL/Python or PL/R which it seems like Heroku does not have either enabled for their postgresql databases. In fact I ran "select lanname from pg_language;" and only got back "internal", "c", and "sql".

I also found some code to do it in pure ruby but that seems somewhat inefficient to me.

I'm rather new to Box Plots, Postgresql, and Ruby on Rails so I'm open to suggestions on how I should handle this. There is a possibility to have a lot of data which is why I'm concerned with performance however if the solution ends up being too complex I may just do it in ruby and if my application gets big enough to warrant it get my ow开发者_运维技巧n Postgresql I can host somewhere else.

*note: since I was only able to post one link, cause I'm new, I decided to share a pastie with some relevant information


Heroku does not give you superuser access on the PostgreSQL cluster, which is required to install any additional languages.

If possible, it's best to perform aggregation server side (in the database) for performance reasons. There are median aggregate implementations which don't need additional languages. By looking at PL/Python boxplot implementations, one should be able to write a PL/pgSQL or PL/SQL equivilant.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜