Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How do I query a large list in SharePoint 2010?

You can use a SPQuery object setting the RowLimit to2000 items or less. You can iterate through the results. Alternatively if you only have one filter in your query, you can use the new SharePoint2010 server specific ContentIterator object. An example here: https://spcounselor-public.sharepoint.com/Blog/Post/2/Querying-a--big-list--with-ContentIterator-and-multiple-filters

user-image
Question added by Deleted user
Date Posted: 2013/09/21
Mohammad Hijazi
by Mohammad Hijazi , System Architect , Department of Education and Knowledge

This topic needs further discussion as it is not easy one, there are a lot of things which you have to take into consideration but this is #1 top performance killers.

Nachiket Kamat
by Nachiket Kamat , Senior Developer Analyst , Remote Software Solutions

There are4 methods:-

1. Use SPQuery.Throttlemode= OverRide/Strict

2. Use SPQuery.RowLimit and paging

3. Disable the list throttling in SSOM or PowerShell and enable it after the query

4. Use RWEP (this method only allows querying20000 items)

Kashif Hafeez Sharepoint Engineer BPM
by Kashif Hafeez Sharepoint Engineer BPM , Software Engineer Sharepoint/Support/BPM , FGB (First Gulf Bank)

CQWP or camel

I am impresssed with CAML and used it inside list to filter data etc.

 

Bowsil Ameen
by Bowsil Ameen , Sharepoint Development officer / architect , Etihad Airways

 

Hello,

 

Good day!!

 

If you are Working with large data retrieval from the content database (SharePoint list) just you have to consider the below points

 

a) Limit the number of returned items.

b) Limit the number of returned columns.

c) Query specific items using CAML (Collaborative Markup Language)

 

Limit the number of returned items

 

SPQuery query = new SPQuery();

 

query.RowLimit =2000; // we want to retrieve2000 items

 

 

 

query.ListItemCollectionPosition = prevItems.ListItemCollectionPosition; // starting at a previous position

 

SPListItemCollection items = SPContext.Current.List.GetItems(query);

 

// now iterate through the items collection

 

 

 

Limit the number of returned columns.

 

SPQuery query = new SPQuery(); query.ViewFields = "";

 

 

 

Query specific items using CAML

 

SPQuery query = new SPQuery(); query.Query = “15”;

 

You can use contains for retrieval of multiple values

 

Ibrahim Khatri
by Ibrahim Khatri , Senior Solutions Architect , Confidential

This is very interesting topic and this actually need to be considered during the design phase of any project as this will drive the performance of your application.

 

To make more clear, SharePoint2010/2013 allows to query5000 items not the2000.

 

There are multiple ways you should actually manage the list in such a way sthat you could avoid this situation.like you create folders or create index on the fields on which you are going to write where clause.

 

I would refer following link to guide you on possible solutions and avoid problems:

http://apmblog.compuware.com/2010/03/18/how-to-avoid-the-top-5-sharepoint-performance-mistakes/

I would also refer the boundary condition link to you so you can plan the data structure in sharepoint site accordingly:

http://technet.microsoft.com/en-us/library/cc262787.aspx

 

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.