On Wed, Oct 1, 2008 at 4:01 PM, Anthony E. <[EMAIL PROTECTED]> wrote: > > Ramon Tayag wrote: >> Book having many :prices does make sense. That way you get to keep >> the history of the price of the book. Of course, the latest price in >> the association is the current price. >> >> Ramon Tayag > > > The problem with that is to get the current price (most uses cases) I > have to scan the entire 'prices' table. >
*sniff* I smell premature optimization. ;-) Seriously, with database indexes... this is doubtful to be an issue. If it's ever an issue you can cache the current price in the book model, but really... I wouldn't be concerned about that for a while. > I'd rather do it in such a way that it only saves the current price, > year, edition, etc. to a "stats" whenever the book is updated (without > any explicit association). This is the case either way. Just not convinced you need to cache this in the Book model from the get-go, which is what you're leaning toward. Cheers, Robby -- Robby Russell Chief Evangelist, Partner PLANET ARGON, LLC design // development // hosting http://www.planetargon.com/ http://www.robbyonrails.com/ aim: planetargon +1 503 445 2457 +1 877 55 ARGON [toll free] +1 815 642 4068 [fax] --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

