Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are alternatives to find_by_sql for computationaly-heavy queries?

Our company loves reports that calculate obscure metrics--metrics that cannot be calculated with ActiveRecord's finders (except find_by_sql) and where ruport's ruby-based capabilities are just too slow.

Is there a plugin or gem or db adapter out there that will do large calculations in the database layer? What's your solution to creating intricate reports?

like image 260
btelles Avatar asked Jun 26 '09 16:06

btelles


2 Answers

Although not database agnostic, our solution is plpgsql functions where it becomes really slow to use Ruby and ActiveRecord.

like image 123
Omar Qureshi Avatar answered Nov 17 '22 03:11

Omar Qureshi


Thoughtbot's Squirrel plugin adds a lot of Ruby-ish functionality to ActiveRecord's find method, with multi-layered conditionals, ranges, and nested model associations:

www.thoughtbot.com/projects/squirrel/

like image 1
Arrel Avatar answered Nov 17 '22 02:11

Arrel