Jay > Which of these two methods would be faster? > > --------- Method 1 --------- > > <cfquery> > SELECT * FROM table WHERE someID = #someVar# > </cfquery> > > <cfif query.recordCount IS 1> > <cfquery>UPDATE table...</cfquery> > <cfelse> > <cfquery>INSERT INTO table...</cfquery> > </cfif> > > --------- Method 2 --------- > > <cfquery> > DELETE FROM table WHERE someID = #someVar# > </cfquery> > <cfquery>INSERT INTO table...</cfquery>
You can achieve an improvement by either: - changing your logic so that you "know" whether to do an update or insert without needing to check the record ID against the database; or - whichever of the 2 methods you use, combining the 2 SQL statements into one stored procedure or at least one CFQUERY. Nick ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Create robust enterprise, web RIAs. Upgrade to ColdFusion 8 and integrate with Adobe Flex http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:287430 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4