I have a simple model called "Search" used to store queries. It captures the URL parameters and stores them in the attribute: search_criteria, which serializes as a hash:
serialize :search_criteria, Hash
It all works fine, but it does awful. For a total of 5 objects, the following statements take approximately 0.2 seconds.
start = Time.now SavedSearch.all.map(&:search_criteria) puts Time.now - start
If, however, I delete the serialization string (such that search_criteria returns the string), the operators take only 0.002 seconds. This is a 2 order difference for hash deserialization !!
What's going on here?
Rails.version = 3.2.8 Ruby 1.9.3p194 (2012-04-20 version 35410) [x86_64-linux]
source share