I need to retrieve items/list items from SharePoint 2010 document library and display it in a list ListView using C#. I have used following CAML query to retrieve list items and its properties.

camlQuery.ViewXml = "<View><Query><Where><Geq><FieldRef Name='ID'/><Value Type='Number'>" + id.ToString() + "</Value></Geq></Where></Query><RowLimit>100</RowLimit></View>"; 
                        ListItemCollection collListItem = oList.GetItems(camlQuery);

                        if (id != 0)
                            items = context.LoadQuery(collListItem.Include
                                                    item => item.File.ListItemAllFields,
                                                    item => item.FileSystemObjectType,
                                                    item => item.Id,                     
                                                    item => item.File,
                                                    item => item.File.ServerRelativeUrl,
                                                    item => item.DisplayName
                                                     ).Where(item => item.Id > id && item.FileSystemObjectType == FileSystemObjectType.File));

Since you would have noticed I have set Row limit to 100 so this works fine, as soon as I increase the limit to about 1000 it slows considerably, taking more than 7 seconds to get query result which is just not acceptable. Is there any other way the I can optimize my query to make it work faster to get about 1000 items in some milliseconds. This is frustrating because reloading items in ListView also adds up to time when loading items using paging.

Need some guidance.



If you find anymore ideas, please post.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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