1

Let's say there is a list with very large number of records. Now applying a particular filter on a list also retrieves very large number of items, more than threshold value. Retrieving list item is creating performance issue. Now, server side code is not permitted, only client side code is permitted. How to tackle this issue? What steps should be taken?

5

You can use CAML queries. These queries are executed in the server and will retrieve only the items requested for.

Use Pagination to iterate through the items. For that you can use ListItemCollectionPosition

Here is a snippet you are use for this

ClientContext clientContext = new ClientContext("weburl");
List list = clientContext.Web.Lists.GetByTitle("ListTitle");
ListItemCollectionPosition position = null;
do
{
    CamlQuery camlQuery = new CamlQuery();
    camlQuery.ListItemCollectionPosition = position;
    camlQuery.ViewXml = @"<View>
                            <ViewFields>
                              <FieldRef Name='Title'/>
                            </ViewFields>
                            <RowLimit>5000</RowLimit>
                          </View>";
    ListItemCollection listItems = list.GetItems(camlQuery);
    clientContext.Load(listItems);
    clientContext.ExecuteQuery();
    position = listItems.ListItemCollectionPosition;
    foreach (ListItem listItem in listItems)
        Console.WriteLine("Title: {0}", listItem["Title"]);
}
while(position != null)
  • Yes this solution is working.. but if we add <Query></Query> and use non index column.. It's not working.. have any solution for this? – SID Mar 2 '17 at 11:26
  • Depends on your requirements ! What you have to do ? – Vladimir Herrlein Feb 2 '18 at 11:09
  • @SID non index column will not work in the caml query, in case if you need to include those columns, you will have to index those columns – Pradeep Apr 17 at 5:09
  • @SID maximum of 20 columns can be indexed – Pradeep Apr 17 at 5:10

protected by Community Apr 12 '18 at 19:11

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.