|
|
Posted Tuesday, August 09, 2011 8:23 PM |
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 5:16 PM
Points: 5,101,
Visits: 20,201
|
|
|
|
|
Posted Tuesday, August 09, 2011 11:06 PM |
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Today @ 12:06 AM
Points: 1,846,
Visits: 974
|
|
Great question.Learned new thing today.
Malleswarareddy I.T.Analyst MCITP(70-451)
|
|
|
|
Posted Wednesday, August 10, 2011 1:05 AM |
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 3:34 PM
Points: 2,170,
Visits: 3,582
|
|
Great article by Paul. Good question, like to see more of these.
Mohammed Moinudheen
|
|
|
|
Posted Wednesday, August 10, 2011 2:12 AM |
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Monday, May 06, 2013 5:31 AM
Points: 2,226,
Visits: 438
|
|
I am surprised that 60% thought it wouldn't increase! Shrinking a databases is like the opposite of defragmentation! I have seen some terrible examples at some clients using "auto shrink" on the databases. Guess what happens to the performance!
Shrinking a database would give you a warning about the fragmentation issues, and auto shrink would send a message to your boss telling him to fire you! :)
/Håkan Winther MCITP:Database Developer 2008
|
|
|
|
Posted Wednesday, August 10, 2011 2:50 AM |
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 9:52 AM
Points: 1,356,
Visits: 4,761
|
|
I didn't have the foggiest, so am one of the 60% who guessed wrongly that it wouldn't increase!
I've never had to work with a database that did anything other than grow
|
|
|
|
Posted Wednesday, August 10, 2011 4:11 AM |
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 4:26 AM
Points: 1,127,
Visits: 619
|
|
I was expecting the fragmentation to grow on the basis that pages at the end of a database file get moved to empty pages earlier during a shrink.
When i tried this out with a new database (512mb data file and 128mb log file) I got a different fragmentation of 46.875% (2008) 70.3125% (2005) before the table drop and the same after the shrink. I have tried it several times on SQL 2005 (9.00.5057) and SQl 2008 (10.50.2500) and get roughly the same fragmentation percentage. During the shrink i got the warning mesage below.
DBCC SHRINKDATABASE: File ID 1 of database ID 34 was skipped because the file does not have enough free space to reclaim.
I tried running the script with 2500 inserts into FirstTable and got exactly the same frgmentation as the question 39.0625% but still got the same warning when trying to shrink the file.
So the correct answer for me was no change. I guess the real answer is "it depends" on your setup.
|
|
|
|
Posted Wednesday, August 10, 2011 5:24 AM |
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Monday, May 06, 2013 5:31 AM
Points: 2,226,
Visits: 438
|
|
j_baldwinson (8/10/2011)
I was expecting the fragmentation to grow on the basis that pages at the end of a database file get moved to empty pages earlier during a shrink. When i tried this out with a new database (512mb data file and 128mb log file) I got a different fragmentation of 46.875% (2008) 70.3125% (2005) before the table drop and the same after the shrink. I have tried it several times on SQL 2005 (9.00.5057) and SQl 2008 (10.50.2500) and get roughly the same fragmentation percentage. During the shrink i got the warning mesage below. DBCC SHRINKDATABASE: File ID 1 of database ID 34 was skipped because the file does not have enough free space to reclaim. I tried running the script with 2500 inserts into FirstTable and got exactly the same frgmentation as the question 39.0625% but still got the same warning when trying to shrink the file. So the correct answer for me was no change. I guess the real answer is "it depends" on your setup.
Your database didn't get shrunk because the space for FirstTable didn't get released for some reason. Try to use CHECKPOINT between them and see if you get a different result.
The point with the question is to demonstrate the issue with shrink and why you should avoid it.
/Håkan Winther MCITP:Database Developer 2008
|
|
|
|
Posted Wednesday, August 10, 2011 6:08 AM |
|
|
SSC-Insane
         
Group: General Forum Members
Last Login: Yesterday @ 7:36 PM
Points: 21,357,
Visits: 9,535
|
|
Very nice question @bitbucket-25253.
I got it wrong because I couldn't choose between 50% and 90%. I knew the heap writes all over the place and that shrink "usually" drives fragmentation over 90%. However in this case I was struggling with the fact that there's only 2 tables. Given that only 1 table was left I was think that all the page would move to the front an be "somewhat" in order.
Loved this question, just giving you pointers for the next ones .
|
|
|
|
Posted Wednesday, August 10, 2011 6:36 AM |
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 4:02 PM
Points: 5,269,
Visits: 11,203
|
|
obviously a very worthwhile educational question on the basis that so many people have thought the shrink would have no affect.
now they know!
---------------------------------------------------------------------
|
|
|
|
Posted Wednesday, August 10, 2011 7:03 AM |
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Today @ 6:19 PM
Points: 3,226,
Visits: 64,185
|
|
|
|
|