From what I've gathered, the changedpages control does a propertycriteria-search and adds pages with a changed-date newer than than x hours to a collection. This is a serious performance killer for a site that has some 1000 pages, and has a frontpage that lists changedpages throughout the solution. Instead, I think this should be solved by doing a simple "order by changed date" SQL statement, and a method that takes in a parameter that specifies the number of hours you want to go back, so that the filtering is done on the db layer. Also, there should be a method that accepts a parameter specifying how many pages you want to retrieve (TOP x), since this is more natural to deal with for a web editor than a certain number of hours. (At least when listing changedpages on the frontpage of a website, it's more natural to say that you want to list x number of recently changed articles, regardless of how old they really are.)
We are dealing with a specific problem related to this right now, where appx 1000 pages is fetched, while we only need/use 15...
Hello Eirik!
Thank you for the input. If I wanted to have the functionallity you are implementing I would do the following:
1. Cache the items you want to show, ie the 15 latest pages for as given amount of time. You could also set a cache key and invalidate the cache on the PublishingPageEvent on DataFactory.
2. If the search is taking to long time and you get way to many results you could do the following (pseudo code):
int hoursToSearch = 2;
PageDataCollection changedPages;
do
changedPages = FetchChangedPagesFunction(hoursToSearch);
hoursToSearch = hoursToSearch *2;
while
changedPages.Count < 15;
Thanks for your input.
Yes, that is in fact EXACTLY what I'm doing now.. including a cache dependency to the episerver cache manager version key, in order to set the cache to expired dynamically. I have also implemented a test that makes sure that the code runs no more than x times. (Might run forever in the odd case that you have less than say 15 articles in the solution)
Still, solving it at a lower level would be preferable, in my opinion.
Regards,
Eirik