| Author |
Topic |
|
enaran
Starting Member
8 Posts |
Posted - 2007-02-11 : 16:38:21
|
| Hi,I am wondering why a database that was 2Gb in size would come down to just 300Mb when I copy all the data from the origional database into a blank new one.I ran a database shrink on the origional database but that only reduced it from 2.1 Gb to 2Gb.I was shocked to see the size difference when I copied the data.As far as I can tell the copied database still contains all the records of the origional.I remember that MSAccess had a Compact function that literally copied all the data from one databse into a new empty one - is there the equivalent for SQL?Any thoughts?Thanks |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2007-02-11 : 16:57:27
|
There are a lot of possible reasons for this.What are the results of this query when you run it in each database?select groupid, AllocatedMB = size/128. , UsedMB = fileproperty( name,'SpaceUsed')/128. , namefrom sysfiles aorder by groupid, fileidexec sp_spaceused null,'true' CODO ERGO SUM |
 |
|
|
enaran
Starting Member
8 Posts |
Posted - 2007-02-11 : 17:13:39
|
| Hi Michael,Results from Origional Database (Large)groupid|AllocatedMB|UsedMB|Name0|0.4922|0.2188|tim_log1|1754.4375|1754.4375|timNew Database with copied records from origionalgroupid|AllocatedMB|UsedMB|Name0|1|0.3438|zzztim_log1|409|409|zzztimCheers |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2007-02-11 : 17:18:50
|
| You didn't run the stored procedure?CODO ERGO SUM |
 |
|
|
enaran
Starting Member
8 Posts |
Posted - 2007-02-11 : 17:33:24
|
| Sorry, I had run it all togetherResults of stored procedureLarge Datadatabase_name|database_size|unallocated spacetim|1754.93 MB|0.10 MBSmall Databasezzztim|410.00 MB|0.10 MB |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2007-02-11 : 17:59:40
|
| The stored procedure produces two result sets.CODO ERGO SUM |
 |
|
|
enaran
Starting Member
8 Posts |
Posted - 2007-02-11 : 18:20:09
|
| Sory Michael,Clearly I am not very good at this.Results of Stored ProcedureLarge DatabaseSet 1database_name|database_size|unallocated spacetim|1754.93 MB|0.10 MBSet 2reserved|data|index_size|unused1796440 KB|571344 KB|164272 KB|1060824 KBSmall DatabaseSet 1database_name|database_size|unallocated spacezzztim|410.00 MB|0.10 MBSet 2reserved|data|index_size|unused418712 KB|319216 KB|85872 KB|13624 KB |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2007-02-11 : 19:11:52
|
| More than likely, your original database was badly in need of reindexing.CODO ERGO SUM |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-02-12 : 02:06:15
|
| DBCC SHOWCONTIG (MyTable) WITH ALL_INDEXESwill show you the fragmentation on a table (and each of the table's indexes), and thus whether it needs reindexing.Results:Scan Density -- 100% is best, 0% worstLogical Scan Fragmentation - Lower is betterExtent Scan Fragmentation - Lower is betterAvg. Bytes free per page - Lower is betterAvg. Page density (full) - Higher is betterDon't worry about any table with very few Pages ScannedKristen |
 |
|
|
|