c# - How to improve selection descendant speed in sitecore? -


i need select children (descendants) items filtered template id, under specific item. can in 3 way:

  1. use getdescendants myitem.axes.getdescendants().where(x => x.isoftemplate(myitem.templateid)).select(x => (myitem)x).tolist();
  2. use xpath

     string q = string.format("{0}//*[@@templateid='{1}']", myitem.paths.path, myitem.templateid);             var result = myitem.database.selectitems(q); 
  3. use sitecore search api

i can't use #3 case. let skip case.

xpath selector #2 should work faster #1, problem in first call path.

by reason first call content tree specific path slow. after first call similar calls works fast, doesn't matter witch style use #1 or #2. sitecore add cache.

how improve speed first call ?

though there many ways retrieve items (using link databse mark cassidy has suggested, using siteocre search api etc.) issue cache. if query runs quick enough second time around first time it's part of cache being emptied , refilled. 1 of following: sqldataprovider - prefetch data master|web [data]
master|web [itempaths]
master|web [items]
master|web [paths]

to investigate this, use admin cache page @ /sitecore/admin/cache.aspx , pay particular attention not cache size, delta (change in cache size) caches might affected. if delta has negative values cache being flushed make room newer data. need @ increasing size of cache.

please bear in mind caching should configured particular environment sitecore instance running in, , e.g. recycling application pool flush cache. if it's essential query runs right start, consider adding specific items prefetch cache. adding items prefetch cache on application startup has cost in startup time.

please remember cache configuration should last resort when looking @ slow running code - merely treats symptoms , not root cause.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -