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.
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.