Skip Ribbon Commands
Skip to main content

Robin | zevenseas | SharePoint Blog

:

The zevenseas Community > Blogs > Robin | zevenseas | SharePoint Blog > Posts > ContentIterator .. part deux
April 07
ContentIterator .. part deux

In my previous post about the ContentIterator I concluded the post with some details about the performance by using a console application and a stopwatch. @Mahoekst asked me if there were any other differences while make calls to the database, so I created a very simple WebPart which does exactly the same as the console app did only know with some more background info using the Developer Dashboard.. and there are some interesting results! The first bit is doing the foreach loop for a large list, it seems while making use of the ContentIterator, it takes the same amount of time but it divides all the calls into separate small chunks (probably that’s the less intrusive bit while talking to the database).

ContentIterator     Vanilla  
SELECT TOP(@NUMROWS) 15.81   SELECT TOP(@NUMROWS) 68.60
SELECT TOP(@NUMROWS) 14.07   SELECT TOP(@NUMROWS) 64.62
SELECT TOP(@NUMROWS) 14.61   SELECT TOP(@NUMROWS) 66.82
SELECT TOP(@NUMROWS) 14.56   SELECT TOP(@NUMROWS) 94.28
SELECT TOP(@NUMROWS) 15.81   SELECT TOP(@NUMROWS) 65.81
SELECT TOP(@NUMROWS) 17.77   SELECT TOP(@NUMROWS) 70.24
SELECT TOP(@NUMROWS) 14.03   SELECT TOP(@NUMROWS) 62.78
SELECT TOP(@NUMROWS) 14.22   SELECT TOP(@NUMROWS) 72.00
SELECT TOP(@NUMROWS) 14.42   SELECT TOP(@NUMROWS) 62.95
SELECT TOP(@NUMROWS) 13.78   SELECT TOP(@NUMROWS) 62.47
SELECT TOP(@NUMROWS) 14.16   Total 690.57
SELECT TOP(@NUMROWS) 13.53      
SELECT TOP(@NUMROWS) 14.11      
SELECT TOP(@NUMROWS) 13.91      
SELECT TOP(@NUMROWS) 13.87      
SELECT TOP(@NUMROWS) 14.07      
SELECT TOP(@NUMROWS) 13.79      
SELECT TOP(@NUMROWS) 13.65      
SELECT TOP(@NUMROWS) 13.74      
SELECT TOP(@NUMROWS) 13.73      
SELECT TOP(@NUMROWS) 14.26      
SELECT TOP(@NUMROWS) 13.87      
SELECT TOP(@NUMROWS) 13.95      
SELECT TOP(@NUMROWS) 13.43      
SELECT TOP(@NUMROWS) 13.85      
SELECT TOP(@NUMROWS) 16.22      
SELECT TOP(@NUMROWS) 15.78      
SELECT TOP(@NUMROWS) 17.62      
SELECT TOP(@NUMROWS) 20.3      
SELECT TOP(@NUMROWS) 16.8      
SELECT TOP(@NUMROWS) 17.96      
SELECT TOP(@NUMROWS) 16.36      
SELECT TOP(@NUMROWS) 16.5      
SELECT TOP(@NUMROWS) 22.35      
SELECT TOP(@NUMROWS) 17.62      
SELECT TOP(@NUMROWS) 18.22      
SELECT TOP(@NUMROWS) 22      
SELECT TOP(@NUMROWS) 17.44      
SELECT TOP(@NUMROWS) 17.87      
SELECT TOP(@NUMROWS) 17.66      
SELECT TOP(@NUMROWS) 17.2      
SELECT TOP(@NUMROWS) 15.43      
SELECT TOP(@NUMROWS) 13.48      
SELECT TOP(@NUMROWS) 15.47      
SELECT TOP(@NUMROWS) 14.04      
Total 703.32      

Here is the table in a graph:

image

As you can see, quite clearly, it’s pretty impressive what the ContentIterator does when making such an expensive request to the database and making it inexpensive by dividing the query into small chunks.

Now I wanted to do something more common.. like looping through every sitecollection, it’s webs and it’s lists. Check out the following piece of code;

foreach (SPSite site in webApplication.Sites)
{
    using (site)
    {
        foreach (SPWeb web in site.AllWebs)
        {
            using (web)
            {
                foreach (SPList list in web.Lists)
                {
                    this.Controls.Add(new LiteralControl(list.Title.ToString()));
                }
            }
        }
    }
}

when using the ContentIterator, this translates to :

ContentIterator contentIterator = new ContentIterator();
contentIterator.ProcessSites(webApplication.Sites,
    delegate(SPSite site)
    {                        
        ContentIterator contentIteratorWeb = new ContentIterator(contentIterator);
        contentIteratorWeb.ProcessSite(site,
            delegate(SPWeb web)
            {
                ContentIterator contentIteratorList = new ContentIterator(contentIteratorWeb);
                contentIteratorList.ProcessLists(web.Lists,
                    delegate(SPList list)
                    {
                        this.Controls.Add(new LiteralControl(list.Title.ToString()));
                    },
                    delegate(SPList list, Exception error)
                    {
                        return true;
                    });
            },
            delegate(SPWeb web, Exception error)
            {
                return true;
            });
            
        
    },
    delegate(SPSite site, Exception error)
    {
        return true;
    });
}

The results are the following (and not quite shocking as the ListItems example is)

ContentIterator     Vanilla  
proc_FetchDocForHttpGet 15.49   proc_FetchDocForHttpGet 11.99
dbo.proc_getSiteNames 2.85   dbo.proc_getSiteNames 2.64
proc_GetTpWebMetaDataAndListMetaData 6.97   proc_GetTpWebMetaDataAndListMetaData 5.53
proc_ListAllWebsOfSite 4.61   proc_ListAllWebsOfSite 3.74
proc_GetTpWebMetaDataAndListMetaData 6.53   proc_GetTpWebMetaDataAndListMetaData 5.93
proc_EnumLists' CommandType: 10.46   proc_EnumLists' CommandType: 7.53
proc_GetTpWebMetaDataAndListMetaData 7.92   proc_GetTpWebMetaDataAndListMetaData 5.79
proc_EnumLists' CommandType: 6.67   proc_EnumLists' CommandType: 4.95
proc_GetTpWebMetaDataAndListMetaData 6.5   proc_GetTpWebMetaDataAndListMetaData 5.31
proc_EnumLists' CommandType: 5.39   proc_EnumLists' CommandType: 4.35
proc_GetTpWebMetaDataAndListMetaData 6.29   proc_GetTpWebMetaDataAndListMetaData 5.22
proc_ListAllWebsOfSite 3.36   proc_ListAllWebsOfSite 3.47
proc_GetTpWebMetaDataAndListMetaData 6.97   proc_GetTpWebMetaDataAndListMetaData 5.32
proc_EnumLists' CommandType: 6.48   proc_EnumLists' CommandType: 6.21
proc_GetTpWebMetaDataAndListMetaData 6.67   proc_GetTpWebMetaDataAndListMetaData 5.93
proc_ListAllWebsOfSite 4.16   proc_ListAllWebsOfSite 3.47
proc_GetTpWebMetaDataAndListMetaData 7.42   proc_GetTpWebMetaDataAndListMetaData 5.68
proc_EnumLists' CommandType: 7.61   proc_EnumLists' CommandType: 6.6
proc_GetTpWebMetaDataAndListMetaData 6.89   proc_GetTpWebMetaDataAndListMetaData 5.6
proc_ListAllWebsOfSite 3.97   proc_ListAllWebsOfSite 3.58
proc_GetTpWebMetaDataAndListMetaData 6.89   proc_GetTpWebMetaDataAndListMetaData 5.27
proc_EnumLists' CommandType: 6.15   proc_EnumLists' CommandType: 4.87
proc_GetTpWebMetaDataAndListMetaData 6.45   proc_GetTpWebMetaDataAndListMetaData 5.42
proc_ListAllWebsOfSite 4.06   proc_ListAllWebsOfSite 3.72
proc_GetTpWebMetaDataAndListMetaData 6.1   proc_GetTpWebMetaDataAndListMetaData 5.19
proc_EnumLists' CommandType: 8.87   proc_EnumLists' CommandType: 7.18
proc_GetTpWebMetaDataAndListMetaData 6.55   proc_GetTpWebMetaDataAndListMetaData 5.62
proc_ListAllWebsOfSite 3.48   proc_ListAllWebsOfSite 3.33
proc_GetTpWebMetaDataAndListMetaData 6.68   proc_GetTpWebMetaDataAndListMetaData 5.48
proc_EnumLists' CommandType: 9.28   proc_EnumLists' CommandType: 6.98
proc_GetTpWebMetaDataAndListMetaData 7.64   proc_GetTpWebMetaDataAndListMetaData 5.3
proc_ListAllWebsOfSite 4.31   proc_ListAllWebsOfSite 3.69
proc_GetTpWebMetaDataAndListMetaData 6.83   proc_GetTpWebMetaDataAndListMetaData 5.5
proc_EnumLists' CommandType: 10.2   proc_EnumLists' CommandType: 7.47
proc_GetTpWebMetaDataAndListMetaData 6.79   proc_GetTpWebMetaDataAndListMetaData 5.58
proc_ListAllWebsOfSite 4.06   proc_ListAllWebsOfSite 3.75
proc_GetTpWebMetaDataAndListMetaData 6.84   proc_GetTpWebMetaDataAndListMetaData 6.14
proc_EnumLists' CommandType: 9.27   proc_EnumLists' CommandType: 7.3
proc_GetTpWebMetaDataAndListMetaData 7.71   proc_GetTpWebMetaDataAndListMetaData 5.82
proc_EnumLists' CommandType: 5.79   proc_EnumLists' CommandType: 5.07
proc_GetTpWebMetaDataAndListMetaData 6.88   proc_GetTpWebMetaDataAndListMetaData 5.21
proc_EnumLists' CommandType: 5.27   proc_EnumLists' CommandType: 4.52
Total 279.31   Total 227.25

image

Comments

There are no comments for this post.
 

 Statistics

 
Views: 2008
Comments: 0
Tags:
Published:1138 Days Ago