Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
Administering
»
Primary Filegroup
12 posts, Page 1 of 2
1
2
»»
Primary Filegroup
Rate Topic
Display Mode
Topic Options
Author
Message
SQLRNNR
SQLRNNR
Posted Wednesday, July 01, 2009 10:09 AM
SSCoach
Group: General Forum Members
Last Login: Monday, May 20, 2013 1:07 PM
Points: 18,733,
Visits: 12,332
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 2008
SQL RNNR
Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #745575
Lynn Pettis
Lynn Pettis
Posted Wednesday, July 01, 2009 10:20 AM
SSC-Insane
Group: General Forum Members
Last Login: Today @ 7:50 PM
Points: 21,624,
Visits: 27,465
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
SQLRNNR
SQLRNNR
Posted Wednesday, July 01, 2009 10:29 AM
SSCoach
Group: General Forum Members
Last Login: Monday, May 20, 2013 1:07 PM
Points: 18,733,
Visits: 12,332
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 2008
SQL RNNR
Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #745596
SQLRNNR
SQLRNNR
Posted Wednesday, July 01, 2009 10:32 AM
SSCoach
Group: General Forum Members
Last Login: Monday, May 20, 2013 1:07 PM
Points: 18,733,
Visits: 12,332
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 2008
SQL RNNR
Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #745598
Michael Valentine Jones
Michael Valentine Jones
Posted Wednesday, July 01, 2009 10:34 AM
SSCrazy
Group: General Forum Members
Last Login: Today @ 6:26 PM
Points: 2,945,
Visits: 10,514
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
SQLRNNR
SQLRNNR
Posted Wednesday, July 01, 2009 10:51 AM
SSCoach
Group: General Forum Members
Last Login: Monday, May 20, 2013 1:07 PM
Points: 18,733,
Visits: 12,332
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 2008
SQL RNNR
Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #745616
Michael Valentine Jones
Michael Valentine Jones
Posted Wednesday, July 01, 2009 12:20 PM
SSCrazy
Group: General Forum Members
Last Login: Today @ 6:26 PM
Points: 2,945,
Visits: 10,514
Did you run the script to see how much space is actually used in each datafile? What were the results?
Post #745681
SQLRNNR
SQLRNNR
Posted Wednesday, July 01, 2009 1:54 PM
SSCoach
Group: General Forum Members
Last Login: Monday, May 20, 2013 1:07 PM
Points: 18,733,
Visits: 12,332
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 2008
SQL RNNR
Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #745729
Lynn Pettis
Lynn Pettis
Posted Wednesday, July 01, 2009 2:00 PM
SSC-Insane
Group: General Forum Members
Last Login: Today @ 7:50 PM
Points: 21,624,
Visits: 27,465
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
SQLRNNR
SQLRNNR
Posted Wednesday, July 01, 2009 2:16 PM
SSCoach
Group: General Forum Members
Last Login: Monday, May 20, 2013 1:07 PM
Points: 18,733,
Visits: 12,332
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 2008
SQL RNNR
Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #745744
« Prev Topic
|
Next Topic »
12 posts, Page 1 of 2
1
2
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.