rails-sqlserver/activerecord-sqlserver-adapter — Issue #158: TinyTDS resultset.each(:cache_rows) default is true
Author: tvw
Created: 2012-01-13 12:45:42+00:00
State: open

As far as I can see, the AR sqlserver adapter uses TinyTDS with the default option :cache_rows being true. This results in caching each row retrieved from the database.

When we take this into account, how ActiveRecords works, when retrieving a set of rows from the database, we have each row twice in memory:

1. in the cache TinyTDS uses
2. in the Enumartion ActiveRecord will produce, which contains each row in form of an ActiveRecord model object.

When retrieving a lot of records from the database, the memory usage dramatically goes up because of 2. But with this adapter you add on top of this, another huge amount of memory usage through 1, where I wonder, wether this is really necessary.

But even with small result sets, you have a higher memory usage per request than necessary.