I am experiencing issues in SharePoint Online with a large document list which contains thousands of records. I am getting the usual list view exceeds 5000 items error for some views, so I am trying to filter these views by a date field. I am seeing some strange results that change based on the order of my where conditions.
When I order by the "Event Date" AND "Division" fields, the query is successful.
<View Scope=\"RecursiveAll\">
<Query>
<OrderBy Override='TRUE'><FieldRef Name='ID' /></OrderBy>
<Where>
<And>
<Geq><FieldRef Name='Event_x0020_Date' /><Value Type='DateTime'>2019-01-01T00:00:00Z</Value></Geq>
<Eq><FieldRef Name='Division' /><Value Type='Text'>{division}</Value></Eq>
</And>
</Where>
</Query>
When I perform the exact same query, but the conditions reversed, I get an error that the view exceeds the list view threshold.
<View Scope=\"RecursiveAll\">
<Query>
<OrderBy Override='TRUE'><FieldRef Name='ID' /></OrderBy>
<Where>
<And>
<Eq><FieldRef Name='Division' /><Value Type='Text'>{division}</Value></Eq>
<Geq><FieldRef Name='Event_x0020_Date' /><Value Type='DateTime'>2019-01-01T00:00:00Z</Value></Geq>
</And>
</Where>
</Query>
It seems to me that SharePoint determines that the first condition is already over 5000 items and just does not bother with the 2nd condition. Am I missing something?