SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


shrinking


shrinking

Author
Message
sandhyarao49
sandhyarao49
SSC-Addicted
SSC-Addicted (463 reputation)SSC-Addicted (463 reputation)SSC-Addicted (463 reputation)SSC-Addicted (463 reputation)SSC-Addicted (463 reputation)SSC-Addicted (463 reputation)SSC-Addicted (463 reputation)SSC-Addicted (463 reputation)

Group: General Forum Members
Points: 463 Visits: 650
Could any one tell me the diff between shrinking and truncating .
defrag and shrinking.
I read bol , but iam not able to understand what exactly happens inside.
KenpoDBA
KenpoDBA
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2632 Visits: 635
Well, if I'm clear on what you're asking, it's about log files, right?

Well, truncating would be removing all inactive portions of the log. So your log is full with stuff it doesn't need anymore, and you get rid of it. But your physical log file that sits out on the drive is still the same size, it's just empty now. So you shrink it to fit the current size of the data. Get it?

As for defragging, that just reorgs the pages to put them back in order so they can be read easily.

Watch my free SQL Server Tutorials at:
http://MidnightDBA.com
Blog Author of:
DBA Rant – http://www.MidnightDBA.com/DBARant

Minion Maintenance is FREE:


Manoj-485464
Manoj-485464
Mr or Mrs. 500
Mr or Mrs. 500 (577 reputation)Mr or Mrs. 500 (577 reputation)Mr or Mrs. 500 (577 reputation)Mr or Mrs. 500 (577 reputation)Mr or Mrs. 500 (577 reputation)Mr or Mrs. 500 (577 reputation)Mr or Mrs. 500 (577 reputation)Mr or Mrs. 500 (577 reputation)

Group: General Forum Members
Points: 577 Visits: 130
As I understand, you were talking about the SQL Logs.

Truncate is not a logged operation and it will remove uncommited transaction from the Log.

Shrinking is nothing but Comprissing. If have any idea about blocks and sectors in Os drives. It will remove unnecessary space from the file and keep one after other.

You can Shrink data file and log file as well.

Defrag means rearranging the pages, so it can easy to read those.

Manoj

MCP, MCTS (GDBA/EDA)

mobasha
mobasha
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1608 Visits: 1284
any way when truncating the log file the operation want be logged cos u cant log the operations on the log file!!
and u cant drop the log file or delete some recoreds from.
its not like when truncate a table.

..>>..

MobashA
tosscrosby
  tosscrosby
SSCertifiable
SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)

Group: General Forum Members
Points: 5866 Visits: 5316
I won't define the topics as that has already been taken care of but I will add my 2 cents, for what it's worth.

1) Truncate - if you truncate the log, do a full database backup immediately afterwards as you've broken your backup chain.
2) Shrinking - unless you had a rare event which caused your log file to grow substantially, don't do it. If the log grew due to normal daily processing, it will likely grow again after the shrink, resulting in a performance hit and potential physical fragmentation.
3) Defrag is fine but you should possibly look for a maintenance window to reindex. I do mine weekly. If you can only do it monthly, maybe defrag at other times to keep things running as smooth as possible.

-- You can't be late until you show up.
Manoj-485464
Manoj-485464
Mr or Mrs. 500
Mr or Mrs. 500 (577 reputation)Mr or Mrs. 500 (577 reputation)Mr or Mrs. 500 (577 reputation)Mr or Mrs. 500 (577 reputation)Mr or Mrs. 500 (577 reputation)Mr or Mrs. 500 (577 reputation)Mr or Mrs. 500 (577 reputation)Mr or Mrs. 500 (577 reputation)

Group: General Forum Members
Points: 577 Visits: 130
Good tosscrosby,

Appreciate for explanation, I forgot to add those point in my previous reply.

Tip of the Day...

"Pages will not migrate between files during an index reorganization".

Manoj

MCP, MCTS (GDBA/EDA)

sandhyarao49
sandhyarao49
SSC-Addicted
SSC-Addicted (463 reputation)SSC-Addicted (463 reputation)SSC-Addicted (463 reputation)SSC-Addicted (463 reputation)SSC-Addicted (463 reputation)SSC-Addicted (463 reputation)SSC-Addicted (463 reputation)SSC-Addicted (463 reputation)

Group: General Forum Members
Points: 463 Visits: 650
Thanks for all of you for your good answers.
Now iam able to uinderstand what happens exactly.

But i have a small doubt.

Index rebuild means it will drops the existing one and creates new one.
In this situation what happens exactly (abt memory and pages wise and the actual process)
tosscrosby
  tosscrosby
SSCertifiable
SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)

Group: General Forum Members
Points: 5866 Visits: 5316
Typically, rebuilds should be run when you can have exlcusive use of the database. It will impact the server performance, it will log to the transaction log, use tempdb and, I think, you should have like 50% of the amount your database size free with respect to disk space for that database (I may be wrong about this number, it may be more!). Defrag can be run with users in the system but again, there will be a performance hit. For index rebuilds, there a plenty of scripts on this site that will allow you to do a selective rebuild, i.e. if the index is x% fragmented, rebuild it, look around if this fits your needs. This would allow for a quicker, possibly smaller, rebuild process.

-- You can't be late until you show up.
Manoj-485464
Manoj-485464
Mr or Mrs. 500
Mr or Mrs. 500 (577 reputation)Mr or Mrs. 500 (577 reputation)Mr or Mrs. 500 (577 reputation)Mr or Mrs. 500 (577 reputation)Mr or Mrs. 500 (577 reputation)Mr or Mrs. 500 (577 reputation)Mr or Mrs. 500 (577 reputation)Mr or Mrs. 500 (577 reputation)

Group: General Forum Members
Points: 577 Visits: 130
Fragmentation exists when indexes have pages in which the logical ordering, based on the key value, does not match the physical ordering inside the data file. All leaf pages of an index contain pointers to the next and the previous pages in the index. This forms a doubly linked list of all index/data pages. Ideally, the physical order of the pages in the data file should match the logical ordering. Overall disk throughput is increased significantly when the physical ordering matches the logical ordering of the data. This leads to much better performance for certain types of queries. When the physical ordering does not match the logical ordering, disk throughput can become less efficient, because the disk head must move back and forth to gather the index pages instead of scanning forward in one direction. Fragmentation affects I/O performance, but has no effect on performance of queries whose data pages reside in the SQL Server data cache.

Manoj

MCP, MCTS (GDBA/EDA)

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search