High performance querying of data in Umbraco V
High performance querying of data in Umbraco V 8 BY PAUL SEAL AND TIM PAYNE
Paul Seal - from Moriyama @Code. Share. Paul Tim Payne @attack_monkey
What are we talking about? ● ● ● A bit of history Performance in V 7 Changes in V 8 Performance in V 8 Caching! Conclusions
A bit of history
● Content internals fairly consistent from V 4 - 7 ● Content was cached in the umbraco. config XML file ● Various APIs sat on top (more added for V 6/7) ● Early days were XSLT and Node based ● Razor and dynamics added in V 6 ● Strongly typed models added later ● Examine/Lucene support too
By the end of V 7 we have MANY APIs ● ● ● ● Document API Node API Dynamic Content (also query by XSLT) Typed Content (also query by XSLT) Content Service Examine Typed. Search Umbraco. library (mostly XSLT)
Performance in V 7
Built a V 7 website, 5000 articles, selected everything!
Getting latest articles!
Searching for articles!
Conclusions for V 7 ● Friends don’t let friends use the content service on the front end ● XPath/XSLT methods are all VERY fast for simple cases ● LINQ fine if used wisely ● Examine the best method for any meaningful searching/sorting
Changes in V 8
Content is now stored in a binary cache called Nu. Cache (lives in /App_Data/TEMP/Nu. Cache) Content API surface GREATLY reduced ● Content Service ● Typed Content (can still use XPath) ● Examine (new version, woohoo)
Interesting notes ● XPath only made to work for MNTP ● Every time Nu. Cache is queried, it caches that query in memory ● There is a Nu. Cache explorer tool which lets you view the Nu. Cache files as JSON ● There is a V 8 package called Our. Umbraco. Nu. Cache. Explorer which lets you view the Nu. Cache files from the backoffice.
Performance in V 8
Built a V 8 website ● Installed Clean Starter Kit ● Created 5000 articles ● Got average times from running each Query Method 1000 times
V 8 Get All Articles
Descendants of Type Example
Children Of Id Example
Children Of Type Example
XPath Greedy Example
XPath Efficient Example
Examine Pure Example
Examine Typed Example
V 8 Get Latest 10 Articles
V 8 Search Page 1
What we noticed in V 8 ● All of the V 8 API methods of searching are way faster than in V 7. ● If you are getting all/latest then it’s faster to use the LINQ methods. ● Examine will perform better on more complicated searches. ● XPath is surprisingly fast.
Caching!
V 8 All Articles With Caching
V 8 Latest Articles With Caching
V 8 Search Page 1 With Caching
Caching Code @using Umbraco. Core. Cache Pass in App. Caches to your constructor, give access to both the Runtime cache and the Request cache Use Get. Cache. Item extension and pass in function used to hydrate: caches. Runtime. Cache. Get. Cache. Item(“latest. News”, () => My. Service. Get. Latest. Articles()); To clear the cache item (say on publish): caches. Runtime. Cache. Clear. By. Key(“latest. News”); Other methods of clearing are available!
No Caching
With Caching
Conclusions
Conclusions LINQ MUCH faster in V 8 Examine is still good for searching. More content = be more careful with LINQ XPath sort of works but is not meant to be used in V 8 anymore ● Caching is good but mainly worth it if you are converting the data to models etc. ● ●
Links Git. Hub Repo - https: //bit. ly/2 Tas. Noi Tim’s V 7 Skrift Article - https: //bit. ly/3 co. Ay 1 p Nu. Cache Explorer Tool - https: //bit. ly/32 Gj 9 w. R Our. Umbraco. Nu. Cache. Explorer https: //bit. ly/2 vt. NDGh
Any Questions?
Thank you for listening!
- Slides: 39