I have a customer with a site that has some performance issues. They enabled some external tool (Solar winds) and found out that a particular SQL statement took up a large amount of time (see images attached)
SELECT DISTINCT EcomGroups.*, EcomShopGroupRelation.ShopGroupShopID AS ShopID FROM EcomGroups FULL JOIN EcomShopGroupRelation ON EcomShopGroupRelation.ShopGroupGroupID = EcomGroups.GroupID
They only place I can find this code is here:
Private Shared ReadOnly Property CachedGroups As Dictionary(Of String, Dictionary(Of String, Dictionary(Of String, Group))) Get Dim storage As Content.Caching.Storage = Content.Caching.StorageManager.Current.GetStorage("eCommerce") Dim groupsDictionary As New Dictionary(Of String, Dictionary(Of String, Group))() Dim groupShopDictionary As New Dictionary(Of String, Dictionary(Of String, Group))() Dim groupsShopWithoutLanguageDictionary As New Dictionary(Of String, Dictionary(Of String, Group))() Dim result As New Dictionary(Of String, Dictionary(Of String, Dictionary(Of String, Group))) If storage.Contains(cacheKey) Then result = storage.Get(Of Dictionary(Of String, Dictionary(Of String, Dictionary(Of String, Group))))(cacheKey) Else 'Load all groups Using groupReader As IDataReader = Database.CreateDataReader("SELECT DISTINCT EcomGroups.*, EcomShopGroupRelation.ShopGroupShopID AS ShopID FROM EcomGroups FULL JOIN EcomShopGroupRelation ON EcomShopGroupRelation.ShopGroupGroupID = EcomGroups.GroupID", "Ecom.mdb") While groupReader.Read() … Build results End While End Using result.Add("GroupsByLanguage", groupsDictionary) result.Add("GroupsByLanguageAndShop", groupShopDictionary) result.Add("GroupsByShop", groupsShopWithoutLanguageDictionary) storage.Insert(cacheKey, result) End If Return result End Get End Property
Looks like this should be called only once and then stored in the cache.
Could there be any reason for this to be not in the cache constantly and lead to almost an hour of execution time?
Some specs:
- DW 8.9.2.20
- Number of products: 37K
- Number of groups: 11114
- Query executes in under a second when executed directly against SQL Server...
Thanks,
Imar