SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Primary Filegroup


Primary Filegroup

Author
Message
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)

Group: General Forum Members
Points: 100258 Visits: 18616
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

Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (150K reputation)SSC Guru (150K reputation)SSC Guru (150K reputation)SSC Guru (150K reputation)SSC Guru (150K reputation)SSC Guru (150K reputation)SSC Guru (150K reputation)SSC Guru (150K reputation)

Group: General Forum Members
Points: 150838 Visits: 39285
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.

Cool
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)
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)

Group: General Forum Members
Points: 100258 Visits: 18616
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

SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)

Group: General Forum Members
Points: 100258 Visits: 18616
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

Michael Valentine Jones
Michael Valentine Jones
SSC-Insane
SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)

Group: General Forum Members
Points: 23887 Visits: 11923
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
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)

Group: General Forum Members
Points: 100258 Visits: 18616
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

Michael Valentine Jones
Michael Valentine Jones
SSC-Insane
SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)

Group: General Forum Members
Points: 23887 Visits: 11923
Did you run the script to see how much space is actually used in each datafile? What were the results?
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)

Group: General Forum Members
Points: 100258 Visits: 18616
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

Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (150K reputation)SSC Guru (150K reputation)SSC Guru (150K reputation)SSC Guru (150K reputation)SSC Guru (150K reputation)SSC Guru (150K reputation)SSC Guru (150K reputation)SSC Guru (150K reputation)

Group: General Forum Members
Points: 150838 Visits: 39285
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.

Cool
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)
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)SSC Guru (100K reputation)

Group: General Forum Members
Points: 100258 Visits: 18616
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

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search