TinyTDS resultset.each(:cache_rows) default is true #158

tvw opened this Issue Jan 13, 2012 · 2 comments


None yet

2 participants

tvw commented Jan 13, 2012

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.


Please read the following. The second is a link I included in my last comment on the first thread.

ActiveRecord, Lazy yielded rows, and row cache

Re: ActiveRecord Performance: Adapter Yielded Non-Cached Rows (Octover 2010)


We only use cache_rows in the stored procedure implementation now.

@metaskills metaskills closed this Jan 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment