Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Recently, we found ourselves in a situation where we suspected that the customer had exceeded our capacity planning guidelines for the number of items in a document library; however, how do we go about verifying that? Well, the steps below will walk you through how to enumerate the counts for the different folders. You have the ability to set a threshold value and report on everything that exceeds that threshold.
Enjoy!
Connect to the SQL server via Microsoft SQL Server Management Studio (SQL 2005) or Query Analyzer (SQL 2000)
Once connected, open a query window
Once you have a query window open, make sure the master database is selected:
Once you have a query window open, paste the following SQL query:
1: create table ##Largelists2: (3: [listID] uniqueidentifier NULL,4: [siteID] uniqueidentifier null,5: [webid] uniqueidentifier null,6: [counts] bigint NULL,7: [fullurl] nvarchar(255) NULL,8: [dirname] nvarchar(255) null,9: [tp_title] nvarchar(255) NULL,10: [servername] nvarchar(100) null,11: [content_DB] nvarchar(100) null12: )13:14: go15: CREATE TABLE #DBNamesLL16: (17: DatabaseName VARCHAR(800),18: RecStatus INT Default 019: )20:21: DECLARE @cmdStr NVARCHAR(2000)22: DECLARE @dbName VARCHAR(500)23: INSERT INTO #DBNamesll (DatabaseName)24: SELECT25: [Name]26: FROM27: sys.databases28: WHERE29: state_desc = 'online'30: ORDER BY31: [Name] ASC32:33: WHILE EXISTS34: (SELECT35: *36: FROM37: #DBNamesLL38: WHERE39: RecStatus=040: )41:42: BEGIN43: SELECT TOP 144: @DbName = DatabaseName45: FROM46: #DBNamesLL47: WHERE48: RecStatus = 049:50: SELECT @cmdStr = N'USE ' + quotename(@dbName, '[') + N';'51: SELECT @cmdStr = @cmdStr + CHAR(13)+CHAR(10) + 'IF EXISTS(SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES with (NOLOCK) WHERE TABLE_NAME = ''namevaluepair'')'52: SELECT @cmdStr = @cmdStr + CHAR(13)+CHAR(10) + 'BEGIN'53: SELECT @cmdStr = @cmdStr + CHAR(13)+CHAR(10) + 'INSERT INTO ##largelists'54: SELECT @cmdStr = @cmdStr + CHAR(13)+CHAR(10) + 'select a.siteid, a.webid, a.listid, count(a.id) [counts], c.fullurl, a.dirname, b.tp_title,'55: SELECT @cmdStr = @cmdStr + CHAR(13)+CHAR(10) + '(@@servername) [servername], (select db_name(dbid) from master..sysprocesses with (NOLOCK) where spid=@@SPID) [Content_DB]'56: SELECT @cmdStr = @cmdStr + CHAR(13)+CHAR(10) + 'from alldocs as a with (nolock) inner join'57: SELECT @cmdStr = @cmdStr + CHAR(13)+CHAR(10) + 'alllists as b with (nolock) on a.listid=b.tp_id inner join'58: SELECT @cmdStr = @cmdStr + CHAR(13)+CHAR(10) + 'webs as c with (nolock) on b.tp_webid=c.id'59: SELECT @cmdStr = @cmdStr + CHAR(13)+CHAR(10) + 'group by a.listid, c.fullurl, b.tp_title, a.siteid, a.webid, a.dirname'60: SELECT @cmdStr = @cmdStr + CHAR(13)+CHAR(10) + 'HAVING count(a.id) > ''1500'''61: SELECT @cmdStr = @cmdStr + CHAR(13)+CHAR(10) + 'END'62: EXEC sp_executesql @Cmdstr63:64: UPDATE65: #DBNamesLL66: SET67: RecStatus = 168: WHERE69: RecStatus = 0 AND70: DatabaseName = @DbName71: END72:73: SELECT74: WebID,75: SiteID,76: ListID,77: tp_Title,78: DirName,79: Counts,80: content_DB,81: servername82: FROM83: ##largelists84: ORDER BY85: counts DESC86:87: DROP TABLE #DBNamesLL88: DROP TABLE ##largelistsIn my OOB configuration, I changed the 1500 value to 300 in order to get some results. Here is what I get:
This indicates that I have 831 list items in the HelpFold/MetaData/1033/MS_OSS folder. It has an associated WebID, SiteID, and ListID shown. There is additional information to the right that identifies the server and the content database where the list is located.
After we have verified that data will actually be returned, we need to save the results to a file in order to get them back to Microsoft. The easiest way to do that is to send the query results to a file.
Now, execute the query again by clicking on the Execute button
When you execute the query, a Save Results dialog will pop up requesting a location for you to save the query results. Specify one that is easy for you to remember:
Now, send the results file (SingleServerLargestFileQuery.rpt) to Microsoft for analysis.
Comments
- Anonymous
December 04, 2008
PingBack from http://stevepietrek.com/2008/12/04/links-1242008-2/