I need to delete the content of the workflow history list that has 18 million items.
I've tried the CSOM code below but it throws a time out error. I couldn't index any columns either through list settings or CSOM. Any help to get rid of these items is greatly appreciated.
This is the CSOM code I've used:
ClientContext context = new ClientContext("https://siteurl");
context.Credentials = new NetworkCredential("username", "pwd", "domain");
List list = context.Web.Lists.GetByTitle("Workflow History");
CamlQuery query = new CamlQuery();
listvalue = txtURL.Text.ToString();
query.ViewXml = "<view><query><where><Eq><FieldRef Name='ID'><Value Type='Number'>1</Value></Eq></where></query></view>";
// query.ViewXml = "<view><query></query><Rowlimit>10</Rowlimit></view>";
ListItemCollection listitemcoll = list.GetItems(query);
context.Load(listitemcoll);
context.ExecuteQuery();
// the code throws error here
foreach (ListItem li in listitemcoll)
{
li.DeleteObject();
}
context.ExecuteQuery();