Alan,

SQL Server will create an execution plan for each query that gets run, where 
the plan is specific to the final Query definition.  From SQL Server's 
perspective, these are 2 different queries, so each gets its own plan:

Query with both names:
>SELECT ID, FName, LName, Email
>FROM SomeTable
>WHERE
>IsActive = 1
>AND
>ClientCode = @param1
>AND Fname  = @param2
>AND Lname  = @param3

Query with last name only:
>SELECT ID, FName, LName, Email
>FROM SomeTable
>WHERE
>IsActive = 1
>AND
>ClientCode = @param1
>AND Lname  = @param2

So, every query I run with only a Last Name filter will re-use that 2nd query 
plan, and that increases performance.  Without using CFQUERYPARAM at all, every 
instance of the query is 'new' and that should (in theory) kill your 
performance, not boost it.  In other words, the following queries would have 
the same plan with params but are each 'new' and distinct without params:

Query with last name only:
>SELECT ID, FName, LName, Email
>FROM SomeTable
>WHERE
>IsActive = 1
>AND
>ClientCode = '1234'
>AND Lname  = 'Smith'

Query with last name only:
>SELECT ID, FName, LName, Email
>FROM SomeTable
>WHERE
>IsActive = 1
>AND
>ClientCode = '1234'
>AND Lname  = 'Johnson'

I'd be curious to see what the Analyzer had to say on the DB server side about 
the query plans for running several hundred unique queries vs several hundred 
recurrences of a few plans.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314615
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