I''m having an argument with my son :) I have a table with about 1500 objects called entries. I need to do something with about 100 of them (schedule manually) I say I should just mark them with a boolean when I have scheduled them. (manual == true) My son says I should pull them out of the entries table and copy them to new objects (lets call them "manual" objects, and store them in the their own table called manuals. I argue that the database pull with a search on a boolean field is not going to be significantly slower than pulling all the objects from the "manuals" table. Anyone have thoughts? Thanks, Shelby -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060802/17f50d03/attachment-0001.html
On 8/1/06, Shelby Westman <shelby.westman@gmail.com> wrote:> I''m having an argument with my son :) I have a table with about 1500 > objects called entries. I need to do something with about 100 of them > (schedule manually) I say I should just mark them with a boolean when I > have scheduled them. (manual == true) My son says I should pull them out of > the entries table and copy them to new objects (lets call them "manual" > objects, and store them in the their own table called manuals. > > I argue that the database pull with a search on a boolean field is not going > to be significantly slower than pulling all the objects from the "manuals" > table.Just to be clear, the way you''re advocating would let you do: Entry.find_all_by_manual true and your son''s way would be Manual.find :alll You should just design the best code you can. If that means doing it your way, well just throw an index on the manual column and let the db take care of it. That doesn''t answer your question...but I think that''s because you''re asking the wrong one. Pat
I think that kid of depends on how different you want the objects to act after they become manual. WIth an index on the boolean I think the speeds will be similar so thats not really the issue. On 8/1/06, Pat Maddox <pergesu@gmail.com> wrote:> On 8/1/06, Shelby Westman <shelby.westman@gmail.com> wrote: > > I''m having an argument with my son :) I have a table with about 1500 > > objects called entries. I need to do something with about 100 of them > > (schedule manually) I say I should just mark them with a boolean when I > > have scheduled them. (manual == true) My son says I should pull them out of > > the entries table and copy them to new objects (lets call them "manual" > > objects, and store them in the their own table called manuals. > > > > I argue that the database pull with a search on a boolean field is not going > > to be significantly slower than pulling all the objects from the "manuals" > > table. > > Just to be clear, the way you''re advocating would let you do: > Entry.find_all_by_manual true > > and your son''s way would be > Manual.find :alll > > You should just design the best code you can. If that means doing it > your way, well just throw an index on the manual column and let the db > take care of it. > > That doesn''t answer your question...but I think that''s because you''re > asking the wrong one. > > Pat > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Elliott Clark eclark@cc.gatech.edu eclark@nife.us
Elliott Clark wrote:> I think that kid of depends on how different you want the objects to > act after they become manual. WIth an index on the boolean I think > the speeds will be similar so thats not really the issue. > > On 8/1/06, Pat Maddox <pergesu@gmail.com> wrote: >> On 8/1/06, Shelby Westman <shelby.westman@gmail.com> wrote: >> > I''m having an argument with my son :) I have a table with about 1500 >> > objects called entries. I need to do something with about 100 of them >> > (schedule manually) I say I should just mark them with a boolean >> when I >> > have scheduled them. (manual == true) My son says I should pull >> them out of >> > the entries table and copy them to new objects (lets call them "manual" >> > objects, and store them in the their own table called manuals. >> > >> > I argue that the database pull with a search on a boolean field is >> not going >> > to be significantly slower than pulling all the objects from the >> "manuals" >> > table.In normal OO design you would expect an object to keep the same class for all its life. Your approach, having a boolean flag, is consistent with that (and your son''s approach is not). If you need special behaviour and/or additional state for manual scheduling, consider having separate ManualTasks that refer to Entries - then the Entry remains in its own table, but you have another class that can provide the machinery related to the manual scheduling of a specific Entry. (ManualTask is just a name I made up - choose a name that suits your application, if you decide to take that approach) regards Justin