I have been searching for ages and trying different solutions but so far nothing makes any difference.
I have a Sharepoint list that has 250-300 items in it. The list has about 40 columns and there is a powerapps form attached to it.
I have a c# application that is trying to interrogate that list to get all of the items that do not have a complete flag set (typically no more than 5-6 items) but the query is taking on average 1min & 40 seconds to complete each time.
I have tried
List item Using indexes,
List item I have tried variations of the CAML query (adding and removing row limits and orderby clauses)
List item I have tried restricting the fields that are returned
List item I have changed the query so it searches by a different field/field type
List item I have tried removing the ListItemCollectionPosition lines
List item and even tried reducing the number of fields it returns to 1 or 2
and nothing seems to make much difference.
Interestingly I have other functions (in the same application) that use exactly the same technique to search for and retrieve one list item from the same list and that works perfectly and really quickly
code that I am using to query:
var context = getUserContext("Team"); List oList = context.Web.Lists.GetByTitle("Job Reference List"); ListItemCollectionPosition itemPosition = null; CamlQuery cQry = new CamlQuery(); cQry.ListItemCollectionPosition = itemPosition; cQry.ViewXml = "<View><RowLimit>40</RowLimit><Query><Where><Eq><FieldRef Name=\"WorkComplete\"/><Value Type=\"Integer\">0</Value></Eq></Where><OrderBy><FieldRef Name = 'Created' Ascending = 'False'/></OrderBy></Query></View>"; ListItemCollection collection = oList.GetItems(cQry); context.Load(collection, items => items.Include( item => item["Title"], item => item["Customer0"], item => item["Install_x0020_Date"], item => item["gpym"], item => item["Engineer"], item => item["Details"], item => item["Job_x0020_Reference"] ), items => items.ListItemCollectionPosition); context.ExecuteQuery();
Any ideas as to where I am going wrong, I would be grateful.