Paul,
After looking into this the bottleneck isn’t with the application code (ASP.NET) but rather in the SQL stored procedure that performs the product lookup, bvc_Product_ByCategoryFiltered_s. The SQL query tests you ran were rather simple compared to what this procedure does. In addition to finding the products that belong to a given category, it also sorts them according to the category sorting setting in the admin and performs an inventory check. The sorting requires an additional table join and the inventory check performs another join and also runs a SQL function. In other words, there’s a lot going on so when you have a large category this negatively impacts performance. Note that it is the category size, not the total size of your catalog, that is causing the problem.
After taking a closer look at how the procedure works I found a few places to optimize it. First, it looks like there are two unnecessary joins. Removing these provides a small improvement in performance. With a category containing 9,000 products I saw the execution time decrease about 1 second from 6 seconds to 5 seconds.
The other place that the query can be optimized is by removing the inventory check. Unfortunately you can only do this if you are not tracking inventory in BV. If that is the case, removing this check will save another 2 seconds, so your execution time is now down to 3 seconds (from 6 seconds).
Attached is a SQL query that will modify the original stored procedure to implement the above optimizations. Note that the changes are simply commented out with a double dash (“--“) at the beginning of the line, so you can always revert back by simply removing them.
To test the procedure before and after, you can execute the following query which returns the first 50 products of your largest category, Supplies:
Code:exec bvc_Product_ByCategoryFiltered_s '27e4b51f-1cb4-4d03-8314-ae57db0291e3', null, null, 0, 50, 0
File Attachment(s):
bvc_Product_ByCategoryFiltered_s.optimized.txt
(6kb) downloaded 85 time(s).You cannot view/download attachments. Try to login or register.