1

I have a question, basically I build a query and use the CrossListQueryCache to retrieve all the required items. Now all was good and well but there is a problem: lists are big some of them more than 5000 items. And ofcourse I get an error of list view threshold.

So I've decided to solve this issue as everyone and everyone says using the indexed column and only retrieving the needed items.

So to test it out I've done following:

CrossListQueryInfo query = new CrossListQueryInfo();                             
query.Lists = "<Lists BaseType=\"0\" />";
query.ViewFields = "<FieldRef Name='ID' /><FieldRef Name='Title' /><FieldRef Name='Creator' />";
query.Webs = "<Webs Scope=\"SiteCollection\" />";
query.RowLimit = 10;           
query.WebUrl = "xxxx";
query.Query = "<OrderBy  Override='True' UseIndexForOrderBy = 'TRUE'><FieldRef Name='ID' Ascending='TRUE'/></OrderBy>";
CrossListQueryCache cache = new CrossListQueryCache(query);
DataTable table = cache.GetSiteData(SPContext.Current.Site);

According to the sources I read, it will only iterate in SQL on indexed column and get 10 of them. ID in SharePoint is always indexed. So the SQL will be something like TOP 10 items from the table.

But the problem I'm still getting an error saying : list view threshold ...

Any idea what I'm doing wrong and how could I solve it.

Cheers

Update: I tried to index another fields, but still without success.

Does cross site query supports indexes?

Final update

To my testing I came to a conclusion that CrossSiteListQuery does not support the indexed columns, no matter what I did I got an error saying threshold list view exceeded. The solution could be to use SPQuery (which does support indexes) and iterate through all the webs and lists to get the items.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.