{"id":27,"date":"2006-04-12T22:12:47","date_gmt":"2006-04-13T03:12:47","guid":{"rendered":"\/cgi\/wp\/?p=27"},"modified":"2006-04-12T22:12:47","modified_gmt":"2006-04-13T03:12:47","slug":"database-code-optimization","status":"publish","type":"post","link":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/?p=27","title":{"rendered":"Database Code Optimization"},"content":{"rendered":"<p>Today I replaced some database code in Storefront 5.0 with some stored procedures. The Storefront code was creating a recordset just to add a new record. I suspect it was selecting all the records, 9889 records in this case, and trying to pull a lot of data from the database when all it meant to do was add one more record. I saw an immediate performance improvement when I replaced the code to insert new order detail records with my stored procedure code.<\/p>\n<p>The reason Storefront used that inefficient method was to get the ID number of the new record that was created without doing another query. But a stored procedure that does an insert can return the new ID number using the SCOPE_IDENTITY() function. SCOPE_IDENTITY() returns the last IDENTITY value inserted into an IDENTITY column in the same scope.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I replaced some database code in Storefront 5.0 with some stored procedures. The Storefront code was creating a recordset just to add a new record. I suspect it was selecting all the records, 9889 records in this case, and &hellip; <a href=\"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/?p=27\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/posts\/27"}],"collection":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=27"}],"version-history":[{"count":0,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/posts\/27\/revisions"}],"wp:attachment":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=27"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=27"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=27"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}