Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Primary Filegroup Expand / Collapse
Author
Message
Posted Wednesday, July 1, 2009 10:09 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 12:11 AM
Points: 17,823, Visits: 15,754
SQL Server 2005
I have moved all user tables and indexes out of the primary filegroup. I have verified that only system objects reside in that filegroup.

The primary filegroup is still 11+ GB used with 8GB free (19GB total size).

Question: How can i find out what is consuming 11GB (since nothing besides system objects reside there)?
My query to find objects and indexes per filegroup:

select 'table_name'=object_name(i.id) ,i.indid
,'index_name'=i.name ,i.groupid
,'filegroup'=f.name ,'file_name'=d.physical_name
,'dataspace'=s.name from sys.sysindexes i
,sys.filegroups f ,sys.database_files d
,sys.data_spaces s
where f.data_space_id = i.groupid
-- and objectproperty(i.id,'IsUserTable') = 1
and f.data_space_id = d.data_space_id
and f.data_space_id = s.data_space_id
-- and i.indid = 1
and s.name = 'Primary'
order by object_name(i.id),f.name,groupid
go


Script to find Filegroup Size
CREATE TABLE #FileDetails (
FileId int , FileGroupId int , TotalExtents int , UsedExtents int ,
"Name" nvarchar( 128 ) , "FileName" nvarchar( 500 ) ,
TotalSize AS ( ( TotalExtents * 64.0 ) / 1024 ) ,
UsedSize AS ( ( UsedExtents * 64.0 ) / 1024 )
)
--Data File Details
INSERT INTO #FileDetails (
FileId , FileGroupId , TotalExtents , UsedExtents , "Name" , "Filename"
)
EXECUTE( 'dbcc showfilestats with tableresults' )
SELECT FILEGROUP_NAME( FileGroupID ) AS FileGroupName ,
FileId ,
"Name" ,
"FileName" ,
(CONVERT(decimal(38,2),TotalSize)) AS FileSizeMB ,
(CONVERT(decimal(38,2),UsedSize)) AS CurrentSizeMB ,
(CONVERT(decimal(38,2),((UsedExtents*1.)/TotalExtents)*100)) AS "%Usage"
FROM #FileDetails

DROP TABLE #FileDetails


I have also defragged all indexes and updated stats (that gave me back about 1GB).




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #745575
Posted Wednesday, July 1, 2009 10:20 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 9:02 PM
Points: 20,734, Visits: 32,515
At this point I'd say shrink the Primary file group. If all you have there now are system objects, no user objects, you can reclaim the unused space.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #745587
Posted Wednesday, July 1, 2009 10:29 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 12:11 AM
Points: 17,823, Visits: 15,754
shrinking only brings me back to the 11GB though. Total size of the filegroup is 19GB and all it will let me reclaim is the 8GB free space.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #745596
Posted Wednesday, July 1, 2009 10:32 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 12:11 AM
Points: 17,823, Visits: 15,754
I would like to get this filegroup down to a reasonable size (500MB seems very large but is what I was able to get my Dev and QA environments down under quite easily).


I just see no valid reason at this point for the size of the primary group to be so big.




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #745598
Posted Wednesday, July 1, 2009 10:34 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Friday, October 3, 2014 2:23 AM
Points: 3,108, Visits: 11,503
Make sure you are doing the shrink the correct way, and that you really have free space in the files. The script on the link below will tell you how much free space you have in each file, and do an incremental shrink.

Shrink DB File by Increment to Target Free Space
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=80355
Post #745600
Posted Wednesday, July 1, 2009 10:51 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 12:11 AM
Points: 17,823, Visits: 15,754
Thanks for the script suggestion. I like the proposed script and concept.


Shrinking the file is of lesser concern to me right now.

The heart of the matter seems to be finding out what is inside that filegroup that I can't seem to locate that is chewing up all of that space.




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #745616
Posted Wednesday, July 1, 2009 12:20 PM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Friday, October 3, 2014 2:23 AM
Points: 3,108, Visits: 11,503
Did you run the script to see how much space is actually used in each datafile? What were the results?

Post #745681
Posted Wednesday, July 1, 2009 1:54 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 12:11 AM
Points: 17,823, Visits: 15,754
After shrinking the primary filegroup (1 file in it), I have no free space. It is currently sitting at 11583 total size and 11572 Used (the used is still increasing with each refresh of the script).

Primary Filegroup is no longer the default, I created a new filegroup to take over for that in the event some table gets created without my knowledge - I don't want it in the primary filegroup.

That said, the fact that the file usage continues to grow in Size also concerns me.


Thanks for the help.




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #745729
Posted Wednesday, July 1, 2009 2:00 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 9:02 PM
Points: 20,734, Visits: 32,515
jason brimhall (7/1/2009)
After shrinking the primary filegroup (1 file in it), I have no free space. It is currently sitting at 11583 total size and 11572 Used (the used is still increasing with each refresh of the script).

Primary Filegroup is no longer the default, I created a new filegroup to take over for that in the event some table gets created without my knowledge - I don't want it in the primary filegroup.

That said, the fact that the file usage continues to grow in Size also concerns me.


Thanks for the help.


Why does it concern you? You may have moved all the user database objects out of the Primary filegroup, but that is where the system database objects reside, and they grow as well as there is activity on those objects, it should be expected. Having removed the user database objects, however, it shouldn't experience as much growth.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #745733
Posted Wednesday, July 1, 2009 2:16 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 12:11 AM
Points: 17,823, Visits: 15,754
I finally pinned it down.

Thanks to the following articles
http://blogs.msdn.com/duncand/archive/2007/01/27/datadude-and-the-text-filegroup.aspx
http://www.sqlservercentral.com/blogs/jeffrey_yao/archive/2009/01/16/list-objects-in-a-filegroup-in-sql-server-2005.aspx


I have several of these still in the primary filegroup.


Working on a solution now to get the LOB Columns moved to a different filegroup




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #745744
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse