I am working in SharePoint 2010, I want to get 500000 "Announcement" list items from the curren开发者_JS百科t spweb. I have a server timeout issue and the code is given below.
SPList list = web.Lists["Announcements"];
SPQuery query= new SPQuery();
query.Query = "<Where><And><Geq><FieldRef Name=\"ID\" /><Value Type=\"Counter\"> 1</Value></Geq><Leq><FieldRef Name=\"ID\" /><Value Type=\"Counter\">500000 </Value></Leq></And></Where>";
query.RowLimit = 500000;
SPListItemCollection items = list.GetItems(query);
DataTable dt = items.GetDataTable(); //Here I get the timeout error.
How do I resolve this issue?
SharePoint's best practices clearly state that no more than about 2000 rows should be in a view.
Best Practices also state that pulling list items programatically should be limited to about 10,000 rows at a time.
Here is a good article to help set reasonable limits for lists:
http://sharepointsearch.com/cs/blogs/notorioustech/archive/2009/04/08/best-practices-for-large-sharepoint-lists-and-documents-libraries.aspx
精彩评论