I am querying a large list and it works well if I don't put any condition in where clause.

I am trying to get items greater than some ID(actual requirement is to get items Created > Today()), as soon as I introduce this condition the query fails with below error :

Additional information: The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator.

ListItemCollectionPosition itemPosition = null;
                    CamlQuery camlQuery = new CamlQuery();
                    camlQuery.ListItemCollectionPosition = itemPosition;
                    camlQuery.ViewXml = "<View Scope='RecursiveAll'>"+
                                    "<Query>" +
                                       "<Where>" +
                                          "<Gt>" +
                                            "<FieldRef Name='ID' />" +
                                            "<Value Type='Counter'>80000</Value>" +
                                         "</Gt>" +
                                       "</Where>" +
                                       "</Query>" +     
                                         "<FieldRef Name='ID'/>" +
                                         "<FieldRef Name='Created'/>" +
                                         "<FieldRef Name='SRNumber'/>" +
                                         "<FieldRef Name='Name'/>" +
                                         "<FieldRef Name='RequestID'/>" +
                                         "<FieldRef Name='Path'/>" +
                                         "<FieldRef Name='AttachmentType'/>" +
                    ListItemCollection collListItem = library.GetItems(camlQuery);
                    itemPosition = collListItem.ListItemCollectionPosition;

                    foreach (ListItem item in collListItem)

                        if (item.FileSystemObjectType.ToString() == "File")
                    if (itemPosition == null)

As per my understanding, I can only use the indexed columns in order to query large list and ID is an indexed column so why it doesn't work?

1 Answer 1


Most likely the issue occurs when we use RecursiveAll. Just curious: do you have many subfolders?

Also, try adding

<OrderBy Override='TRUE'><FieldRef Name='ID' />

before your <Where>

  • Thanks Denis. Yes there are may subfolders and the above mentioned suggestion is not working. The query should look like this ? "<View Scope='RecursiveAll'><Query><OrderBy Override='TRUE'><FieldRef Name='ID' />" +"<Where>"
    – Ishan
    Dec 3, 2018 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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