February 3, 2010 at 7:18 am
Tara-1044200 (2/3/2010)
I dont think reindexing helped me because reindex will rebuild all indexes and my database grown instead of reclaiming space back.Only 1 solution i see getting my space back after deleting columns is exporting the data to a new database.
Something is wrong in this picture ....
Your db needs some spare space !
(a 200MB database is a small db.)
You can rebuild a single table or index ( clustering indexes may cause NCI to be rebuild as well )
On a 2 or 3 MB table (data size), what will be the impact of a rebuild ??
Check out BOL for "Create index" and see what space influating options you have.
( PAD_INDEX / FILLFACTOR )
Can you post @@version info of your sql instance ?
ALTER INDEX [CLIX_Yourtable] ON [dbo].[T_Yourtable] REBUILD -- WITH ( ONLINE = ON ) ;
GO
ALTER INDEX [NCI1_Yourtable] ON [dbo].[T_Yourtable] REBUILD -- WITH ( ONLINE = ON ) ;
GO
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data and code to get the best help
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
February 3, 2010 at 7:25 am
all tables which are in question pretty much increased in space
version :
Microsoft SQL Server 2005 - 9.00.4035.00 (X64) Nov 24 2008 16:17:31 Copyright (c) 1988-2005 Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 5.2 (Build 3790: Service Pack 2)
February 3, 2010 at 7:57 am
Tara-1044200 (2/2/2010)
Here is another interesting thing... I did an export of the whole database into a new test database and the size seems to went down to 142MBCan some one explain technical reason behind this behaviour ?
SQLServer doesn't release space it uses.
Once a file has grown, it will stay that way untill you shrink it.
In many cases such a shrink is not advised, because sqlserver needs some spare space.
On production systems, do NOT enable autoshrink for your database, because you have no controle over the "when" the system will decide to start a shrink operation, and your db-users may notice such an operation to be quit intrusive.
use [yourdb]
exec sp_helpfile
go
/* show space consumption of objects */
Select quotename(object_schema_name(object_id)) + '.' + quotename(object_name(object_id)) as TbName
, Page_count * 8 /1024 as Pages_MB
, *
from SYS.DM_DB_INDEX_PHYSICAL_STATS (13,NULL,NULL,NULL,'detailed' )
order by Pages_MB desc, avg_fragmentation_in_percent desc
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data and code to get the best help
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
February 3, 2010 at 8:53 am
so far i didnt get any explanation for why space is not reclaimed when column are deleted even after shrinking.
technically when data is deleted and then shrinked i have to get space back but why not ?
February 3, 2010 at 1:15 pm
Tara-1044200
so far i didnt get any explanation for why space is not reclaimed when column are deleted even after shrinking.
For an explanation of what happened read these 2 articles:
Changing Table Schema – what goes behind the scenes – Part I at:
http://www.sqlservercentral.com/articles/Design+and+Theory/67552/
Changing Table Schema – what goes behind the scenes – Part II
http://www.sqlservercentral.com/articles/Design+and+Theory/67553/
February 3, 2010 at 8:23 pm
Tara-1044200 (2/2/2010)
I dont have any indexes on any tables in that database.Can you some one give correct explanation as to why space is not released when some column are deleted?
Tara-1044200 (2/3/2010)
I dont think reindexing helped me because reindex will rebuild all indexes and my database grown instead of reclaiming space back.Only 1 solution i see getting my space back after deleting columns is exporting the data to a new database.
Ok... I'm officially confused. How did you reindex if you "don't have any indexes on any tables in that database"?
--Jeff Moden
Change is inevitable... Change for the better is not.
February 3, 2010 at 8:53 pm
As a side bar, I don't use the BIT datatype for the most part. A single bit still takes a byte to store it and you can't so SUM aggregations on the BIT datatype should the need ever arise.
--Jeff Moden
Change is inevitable... Change for the better is not.
February 4, 2010 at 3:18 am
Actually.. I am sorry, i do have indexes.
I am changing INT data type to BIT, does it not save any sapce to me ?
February 5, 2010 at 4:30 am
Michael Swart in this blog post adds to animals argument:
This suggests that an index or table rebuild is the way to claim the space back...
Gethyn Elliswww.gethynellis.com
February 5, 2010 at 4:50 am
Tara-1044200 (2/4/2010)
Actually.. I am sorry, i do have indexes.I am changing INT data type to BIT, does it not save any sapce to me ?
it can save you 3 bytes per row for a single INT column.
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data and code to get the best help
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
February 5, 2010 at 9:23 am
Tara-1044200 (2/4/2010)
Actually.. I am sorry, i do have indexes.I am changing INT data type to BIT, does it not save any sapce to me ?
Like ALZDBA stated, 3 bytes for each row... a single BIT column will still occupy one byte. IIRC correctly, SQL Server will do a bit of conservation by combining up to 8 bit columns in a single byte but I'm not 100% sure on that... I don't know the internals as well as some folks. I also avoid the BIT datatype whenever possible for the reasons I previously stated so I haven't spent a whole lot of time researching it.
--Jeff Moden
Change is inevitable... Change for the better is not.
February 5, 2010 at 11:50 am
Indeed the first bit will take a byte, but a byte can host 7 bits (the 8-th one is used for marking another bit-hosting byte is in the row).
That's how I understood it works.
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data and code to get the best help
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
February 5, 2010 at 11:59 am
Very cool. Thanks Johan.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 13 posts - 16 through 28 (of 28 total)
You must be logged in to reply to this topic. Login to reply