I have no scientific evidence to back me up, but I would use the second
"list" method in the query.  I would think that the optimizers would
handle a list better than multiple ORs.  Also, it's easier to read.

If you have control over the structure of the database, you may be
better off changing the structure from having multiple columns
(instructor1id, instructor2id, etc), to a separate table for instructor
enrollments.

Typically, a course management system would have the following tables:

Courses
-------
course id
course name

Users
-----
user id
user name

Enrollment
----------
course id
user id
role

M!ke 

-----Original Message-----
From: Will Tomlinson [mailto:[EMAIL PROTECTED] 
Sent: Saturday, October 20, 2007 9:31 PM
To: CF-Talk
Subject: Which query would be better?

MySQL 5. 

Which would be the better choice for a report table. I'm concerned and
want the query to run as fast as possible because there could end up
being millions of records in it.

I could add the number of fields I need (not worried about the
flattening of this table and lack of normalization). Instructor1,
instructor2, 3, 4, etc.

Then query like this:

AND (e2.instructor1id =
    <cfqueryparam value="#ARGUMENTS.instructor#">
  OR e2.instructor2id =
    <cfqueryparam value="#ARGUMENTS.instructor#">
  OR e2.instructor3id =
    <cfqueryparam value="#ARGUMENTS.instructor#">
        )

OR ... I could easily create a list of values, then use the IN keyword:

AND someotherfield IN (<cfqueryparam value="#ARGUMENTS.somevaluelist#"
list="yes">)

Thanks,
Will

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Enterprise web applications, build robust, secure 
scalable apps today - Try it now ColdFusion Today
ColdFusion 8 beta - Build next generation apps

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:291686
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to