In ruby on rails, is it possible to do a sum query with group by using the find_each batching?
        Posted  
        
            by BarryOg
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by BarryOg
        
        
        
        Published on 2010-05-19T12:18:41Z
        Indexed on 
            2010/05/19
            12:20 UTC
        
        
        Read the original article
        Hit count: 173
        
I'm loading data from my database and I'm doing a sum calculation with a group by.
ElectricityReading.sum(:electricity_value, :group => "electricity_timestamp", :having => ["electricity_timestamp = '2010-02-14 23:30:00'"])
My data sets are extremely large, 100k upwards so I was wondering if its possible to use the find_each to batch this to help with memory overhead.
I can write the batching manually use limit and offset I guess but I'd like to avoid that if the code already exists.
© Stack Overflow or respective owner