I have created a document library for uploading the Contracts related document. In the application page I have written the code to display the metadata properties like below:
SPList list = SPContext.Current.Web.Lists["Contracts"];
SPListItem item = list.GetItemById(407);
This code was worked perfectly when I tested with 500 documents in my library.
6 Months Latter….
When user click the link to view the metadata for particular document the above code will take around 30 Seconds to display the result.
So I have started my root cause analysis and noticed that the document count in the contracts library is nearly 100 thousand.
After little analysis I have used the CAML query to get the item from my document library using the below code:
SPList list = SPContext.Current.Web.Lists["Contracts"];
SPQuery query = new SPQuery();
query.Query = string.Format("<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>{0}</Value></Eq></Where>","407");
SPListItem item = list.GetItems(query)[0];
This code returns the data in 3 Seconds.
Conclusion:
Even though the item count is less, try to use the CAML query to filter the items from your list or library.
We will see more about SharePoint Performance optimization.
cb3b91fe-3870-4ae4-a733-7f889998a776|0|.0
SharePoint Performance
SharePoint Performance