> I agree with Jochem's suggestion of using cfswitch for numeric or perhaps > single character searches.
The problem as noted in the link Jochem provided is that when using cfswitch, CF under the hood attempts a toDouble(), which if it is numeric hums happily along. If you pass in any type of string (including single character searches), CF internally throws an error which it catches and then attempts to re-process the cfswitch as a string. When a cfswitch is put in a loop (including queries) and uses strings is when this problem becomes more apparent. On an application with moderate load this could be the cause of performance problems. > If the weight of all decisions is equally probably, you could argue the > useage of cfswitch. I disagree. Based on the way the CF calculates a cfswitch, if you are within a loop and using a string for your case elements, there is no question IMO but to refactor the code to use cfif / cfelseif. > Jochem also has a very good answer to this solution. "Why are you just > taking my word for it?" Exactly. Test it yourself. He found the > solution > for a finite and given solution set. Is it the exact culprit for your > latency issues? That would be too general to assume. I am not saying this is a magic bullet solution to all performance problems, but am advocating that people understand what is happening behind the scenes when using cfswitch and to be careful of using it in this type of a case. If someone IS using cfswitch in this mannor, it is undoubtedly causing latency, it is just a matter or whether it is enough to be a problem. > I have sincere issues myself putting CF logic into my queries. I let the > DB > handle this type of logic in the form of stored procedures, which will > calculate my execution plan for me in advance. I completely agree when possible, but this issue also affects loops as well, not just query loops. Rich Kroll ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Upgrade to Adobe ColdFusion MX7 Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs http:http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:268131 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

