From: Ryan Davis Date: 2012-11-10T03:43:13+09:00 Subject: Re: Ruby on Rails: serialize Hash incredibly slow This list is for ruby, not rails... On Nov 9, 2012, at 2:56, "Ruben S." wrote: > (cross post from > http://stackoverflow.com/questions/13292477/ruby-on-rails-serialize-hash-incredibly-slow, > but I haven't gotten an answer yet) > > I've got a simple model called "Search" used for storing searches. It > captures the URL params and stores them in an attribute > :search_criteria, which is serialized as a Hash: > > serialize :search_criteria, Hash > > This all works perfectly, but it performs horribly. For only 5 objects, > the following statements take roughly 0.2 seconds. > > SavedSearch.all.map(&:search_criteria) > > If, however, I remove the serialize line (such that search_criteria > returns a string) the statements take only 0.002 seconds. That's 2 > orders of magnitude difference for deserializing a Hash!! > > What's happening here? I've tried this on multiple systems, including > Heroku, and it's the same everywhere. > > Rails.version = 3.2.8 > > Ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] > > -- > Posted via http://www.ruby-forum.com/. >