Interesting Idea for Efficiency – Avoid SPList.Items…

An interesting post by Rob Garrett about avoiding using SPList.Items.Add() – as referencing SPList.Items causes you to get all items in a list, and that can be pretty slow. He does suggest a solution.

I must confess, I’m surprised. I mean, what he describes makes sense – and also explains why have both SPList.ItemCount and SPList.Items.Count (same problem – and the former should be faster) – but surely there is some equivalent already build, some SPList.AddItem() to do it for you? Guess not.

Might be a small optimisation, but it starts to become clearer why the 2000 item recommendation…

At some point, I’ll try and generate some metrics, and then we’ll see when it becomes more efficient and how much so.

Advertisements
Interesting Idea for Efficiency – Avoid SPList.Items…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s