Saturday, June 13, 2009

DBCC SHRINKDATABASE Will it cause Index Fragmentation Series 4 (Explanation)

Well as I learnt in previous blog Shrink Database caused fragmentation, but why? Before we discuss fragmentation, let me try to explain DBCC ShrinkDatabase command.

DBCC ShrinkDatabase command takes database name, Target Percent and Truncate | NoTruncate as parameters.

Truncate or NoTruncate indicate to database engine if space reclaimed by database engine be given back to Operating System or not.

Truncate: SQL Database engine releases space to OS, NOTruncate: Does not release space to OS though file content is  (leaving empty space at the end).

Target Percent is slightly confused here. Target Percent is not Target Size that database should be post shrinking operation but Target Percent is Target free space database should have post shrinking.

When database is shrunk either by Management Studio or DBCC command it moves data from end of file to beginning or starting of file. It tries to fill pages as it gets to move from end to start of file. So pages can not be moved in chunks (as there may not be huge chunks of pages at start in a normal production environment) but pages maybe moved individually inducing fragmentation.

In this case I have learnt that a completely defragmented index is fragmented to 97% post shrink operation and that is terrifying with regards to performance. Are you all seeing the same :)

Thus if one if forced to do a shrink operation it should be followed by a rebuilding Index (DBCC DBREINDEX) to defragment index.

Also this is one of reasons for Auto Shrink Database Property to be turned off.

Now in a later post I would like to check if Compressing and Decompressing an existing table will induce fragmentation or not or maybe something more interesting :)

If you have any questions / comments / corrections pertaining to any of fragmentation details please feel free to send mail to me at gurucb@hotmail.com

3 comments:

Anonymous said...

Make the animalistic with two backs casinos? separate this advanced [url=http://www.realcazinoz.com]casino[/url] superintend and uphold a combat up online casino games like slots, blackjack, roulette, baccarat and more at www.realcazinoz.com .
you can also dilly-dallying our good palate [url=http://freecasinogames2010.webs.com]casino[/url] evade at http://freecasinogames2010.webs.com and be winning in open compressed create of !
another girder [url=http://www.ttittancasino.com]casino spiele[/url] idea is www.ttittancasino.com , in compensation german gamblers, collect well-wishing online casino bonus.

Anonymous said...

Making money on the internet is easy in the underground world of [URL=http://www.www.blackhatmoneymaker.com]blackhat code[/URL], It's not a big surprise if you haven’t heard of it before. Blackhat marketing uses not-so-popular or little-understood methods to generate an income online.

Anonymous said...

good sams travel clubs http://jtfb.info/shemale/salma-shemale salma shemale [url=http://jtfb.info/pissing/glamorous-ladies-stockingtops-garters-pissing]glamorous ladies stockingtops garters pissing[/url]
http://jtfb.info/nylon/tytan-international-twisted-nylon-twine tytan international twisted nylon twine don moen music [url=http://jtfb.info/pissing/grannies-pissing-pics]grannies pissing pics[/url]
[url=http://jtfb.info/thong/worlds-most-confortable-thong]worlds most confortable thong[/url] anne hathways new movie http://jtfb.info/tit/big-tit-exhibisionist big tit exhibisionist
travel tibet http://jtfb.info/nylon/uncle-mikes-nylon-shot-gun-slings uncle mikes nylon shot gun slings [url=http://jtfb.info/tits/mileys-tits]mileys tits[/url]
http://jtfb.info/prostitute/charlize-theron-prostitute-scenes-online charlize theron prostitute scenes online new orleans jazz funeral music [url=http://jtfb.info/defloration/littel-defloration]littel defloration[/url]