Faster? database search or rewriting objects

I’m having an argument with my son :slight_smile: 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

On 8/1/06, Shelby W. [email protected] wrote:

I’m having an argument with my son :slight_smile: 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 M. [email protected] wrote:

table.

That doesn’t answer your question…but I think that’s because you’re
asking the wrong one.

Pat


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


Elliott C.
[email protected]
[email protected]

Elliott C. wrote:

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs