Search This Blog

Monday, May 2, 2011

Sharepoint 2007 performance tips : Part 2 : fetching data from large lists

Fetching data from large lists while maintaining good performance and response times can be a challenging task.
One of the common coding mistakes is extensive use of collections like 'list.Items' which selects all items in the list with all fields resulting in bad performance.The following alternatives can be used instead to improve the performance in sharepoint 2007 while fetching data from lists:

Alternatives to SPList.Items

Poor Performing Methods and Properties                                  Better Performing Alternatives 

SPList.Items.Count                                                                          SPList.ItemCount

SPList.Items.XmlDataSchema                                                         Create an SPQuery object to retrieve only the items you want.

SPList.Items.NumberOfFields                                                         Create an SPQuery object (specifying the ViewFields) to retrieve only the items you want.

SPList.Items[System.Guid]                                                              SPList.GetItemByUniqueId(System.Guid)

SPList.Items[System.Int32]                                                             SPList.GetItemById(System.Int32)

SPList.Items.GetItemById(System.Int32)                                        SPList.GetItemById(System.Int32)

SPList.Items.ReorderItems(System.Boolean[],System.Int32[],System.Int32)   Perform a paged query by   using SPQuery and reorder the items within each page.

SPFolder.Files.Count                                                                      SPFolder.ItemCount

No comments:

Post a Comment