damianham wrote:
[...]
> 
> If the 'folder.files' element was an array of ids then there would be
> no subsequent database access to determine the size() value.

Not really true; it takes a query in either case.  Your method still 
needs "SELECT file_ids FROM folders WHERE id = ?".  That's not really 
going to perform any better than "SELECT count(*) FROM files WHERE 
folder_id = ?", especially not if files.folder_id is indexed.

If you're really worried about performance, just cache Folder.file_ids 
so you don't have to query it every time.

Or you could use a nested-set tree model (there are several Rails 
plugins that make this easy).  But storing the child keys in the parent 
DB record is just asking for trouble.

> 
> regards
> damian

Best,
--
Marnen Laibow-Koser
mar...@marnen.org
http://www.marnen.org
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to