Our site has a few performance issue which I've compensated for with some view/ donut caching. However I'd like to get to the root of the problem and I wondered about the dictionary. The dictionary is used extensively so that ALL ancillary text is contained in here. These items don't appear to be in the content cache so I'm curious, is the CMS making an new SQL query for each dictionary item and on every request?
To answer my own question, it does appear a new SQL query is made for each Dictionary item when it is first used and it is then cached. This is a bit shonky, but the workaround is to cache all dictionary items when the app starts and then call on my own cache - unless someone has a better way?
I mean that the dictionary items each generate a DB query is shonky, as the overhead is much larger than a single query, rather than my workaround is shonky.
I'm not sure there is even caching on first lookup. I am seeing a SQL hit every time my page is loaded for each lookup. Poking around in the DefaultCultureDictionary implementation, I don't see what caching is going on other than the Language:
Not sure if this is something that can help you but I had some issues with the Dictionary as it will sometimes always make SQL hit. For example when the key is not available anymore. I did not like it making the first request slow for the user, would rather want it to be ready on first request.
So I made a small project that fetches all keys on startup and fills cache. Then there are helpers you can use.
Umbraco.GetDictionaryValue("key")
would be
Umbraco.DictionaryValue("key")
Dictionary performance issues?
Our site has a few performance issue which I've compensated for with some view/ donut caching. However I'd like to get to the root of the problem and I wondered about the dictionary. The dictionary is used extensively so that ALL ancillary text is contained in here. These items don't appear to be in the content cache so I'm curious, is the CMS making an new SQL query for each dictionary item and on every request?
To answer my own question, it does appear a new SQL query is made for each Dictionary item when it is first used and it is then cached. This is a bit shonky, but the workaround is to cache all dictionary items when the app starts and then call on my own cache - unless someone has a better way?
Hi David,
Nice solution!
Why is it a bit shonky?
Why caching all items on app start is better?
Thanks,
Alex
I mean that the dictionary items each generate a DB query is shonky, as the overhead is much larger than a single query, rather than my workaround is shonky.
Yes, David, you are right. I think Umbraco has to improve this functionality.
I'm not sure there is even caching on first lookup. I am seeing a SQL hit every time my page is loaded for each lookup. Poking around in the DefaultCultureDictionary implementation, I don't see what caching is going on other than the Language:
https://github.com/umbraco/Umbraco-CMS/blob/18deb8ad99bce0b19372d90f8c0fabad36beeb50/src/Umbraco.Web/Dictionary/UmbracoCultureDictionary.cs
Hi,
Not sure if this is something that can help you but I had some issues with the Dictionary as it will sometimes always make SQL hit. For example when the key is not available anymore. I did not like it making the first request slow for the user, would rather want it to be ready on first request.
So I made a small project that fetches all keys on startup and fills cache. Then there are helpers you can use.
Umbraco.GetDictionaryValue("key") would be Umbraco.DictionaryValue("key")
https://github.com/Vettvangur/Vettvangur.DictionaryHelper
@Garðar Þorsteinsson Nice :-)
is working on a reply...