The official website of Bipul Raman

Performance enhancement tips while using CAML Query in SharePoint

No comments

Putting a lot of design customization, custom codes on SharePoint may cause several performance issues. But the main challenge for a developer is to fulfill all the feasible business requirement of client without hitting down the performance. Enhancing performance cannot be done in single step. In fact, at every step of coding you need to take care of it. You need to review every single line of code and justify if it is really needed or can be optimized in other way.

In this article, I will be discussing performance enhancement tips very specific to CAML Query. Whenever you are requesting any data from SharePoint, you use CAML query to filter it based on your parameters. You can use these parameters in CAML Query to enhance the performance.
  • Where : To put conditions or filters such as equals, contains etc.
  • OrderBy : To order the data. Instead of manipulating data later, do it in CAML itself.
  • ViewFields : To load data from selective fields
  • RowLimit : To load data in limited counts
Here is a sample CAML Query which is getting data from a list putting these parameters
  • When List Item Title is equal to 'Test'
  • Ordering data in Ascending Order
  • Loading data for only two fields: 'Title' & 'Code' 
  • Loading only 3 list items
<ViewAttributes Scope="RecursiveAll" />
is used to load data from folders situated inside the lists.

Always remember, this thumb rule while requesting any data from the server
"Request only those data which is really required"

No comments :

Post a Comment