Dominic, you are right that there are exceptions from a performance 
perspective ... can't remember who blogged about that in detail?  See Simon 
Horwith's for one example: 
http://www.horwith.com/index.cfm/2009/4/5/some-cf-best-practices-that-break



But you are right about the Query Plan getting cached.  Not every value has 
to be a parameter, however, the query just has to be exactly the same.  So, 
if it only ever looks like this:

SELECT fu
FROM bar
WHERE barId = <cfqueryparam cf_sql_type="cf_sql_integer" value="#id#" />
AND live = 1

Then that will cache just fine, regardless of the value of #id#.  If, 
however, you also have a query for archived:

SELECT fu
FROM bar
WHERE barId = <cfqueryparam cf_sql_type="cf_sql_integer" value="#id#" />
AND live = 0

Then those 2 will have separate Query Plans on the DB server.  By contrast, 
if the 'live' value is param'd, then you can re-use the Query Plan for both 
queries:

SELECT fu
FROM bar
WHERE barId = <cfqueryparam cf_sql_type="cf_sql_integer" value="#id#" />
AND live = <cfqueryparam cf_sql_type="cf_sql_bit" value="1" />

would use the same QP as 

SELECT fu
FROM bar
WHERE barId = <cfqueryparam cf_sql_type="cf_sql_integer" value="#id#" />
AND live = <cfqueryparam cf_sql_type="cf_sql_bit" value="0" />

 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:321687
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to