On Aug 15, 11:08 am, Clive <[email protected]> wrote:
> In edge rails,  serialized attributes are saved every time no matter
> they are changed or not:
>     def update_with_dirty
>           if partial_updates?
>             # Serialized attributes should always be written in case
> they've been
>             # changed in place.
>             update_without_dirty(changed | (attributes.keys &
> self.class.serialized_attributes.keys))
>           else
>             update_without_dirty
>           end
>         end
>
> In out app, User model has a serialized attribute friend_ids, which is
> the id array of the user's friends (used to be a friendships table,
> but when that table grew to tens of millions of records, we refactored
> it to a User's attribute). The User model in our app is saved very
> frenquently, and many users have more than 1 handred friends, so the
> friend_ids may has 1kB long. Some of my colleages opposed to use
> serialized friend_ids, and suggested to used a comma separated string
> instead because saving 1kB each time would have performance issue.

Well before rails 2.1 partial updates didn't exist at all and the
world continued to function :-)
The simple to solution is to benchmark it - monkey patch stuff so that
this does happen, measure, monkey patch it so that is doesn't, measure
again.

Another possible way would be to  stick the friend_ids data in its own
table. This might also save you loading it unecessarily

Fred
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to