Content Query Webpart

Recently I was working on an issue where a SPS site had a Content Query Webpart pulling data from the document library of custom content types inside the top level site.

When we create a new site under the top level site collection the Content Query Webpart fails to show the data and instead displays :

"There is a problem with the query that the web part is using. Check the configuration of the web part and try again..."

The Site collection had more than 200 sites under the top level site.

Each site has multiple document libraries. We found that the issue happens only when we add more document libraries in the new site.

If we reduced the sites from the site collection we were able to add more document library in the new site and the Content Query Webpart still worked.

Hence we suspected that we might be reaching content query webpart limits.

Content Query Web Part

The Content Query Web Part utilizes the Windows SharePoint Services cross-list querying mechanism to retrieve content from a SharePoint site collection. If the Web Part is configured to issue a query that involves a large number of lists, the cross-list query mechanism may raise an exception.

By default, cross-list queries have a list limit of 1,000. This means that if you configure the Content Query Web Part with a query that includes more than 1,000 lists, the cross-list query will not complete, and the Web Part will not show any content. The reason for this throttling is to avoid overburdening SQL Server 2005.The more lists the cross-list query includes, the longer it takes for the database server to return the content the query is asking for. For very large numbers of lists, this could cause the database server to disproportionately process cross-list queries at the expense of other requests.

If your requirements involve querying for more than 1,000 lists, you can increase the list limit if the database load that the operations require is acceptable. You can do this by adding a MaxListLimit attribute to the ListsOverride property of the Web Part. For example, if you wanted to raise the list limit to 2000, you would set the ListsOverride property as:
 <Lists ServerTemplate="850" MaxListLimit="2000">