Avatar of Vijay
Vijay
 asked on

Shrinking MS SQL Log file

Hi Team,

My Db is in simple recovery mode.  This is not PROD. So backups are not important for us.

What if i shrink .ldf files? will it cause fragmentation?
Microsoft SQL ServerSQL

Avatar of undefined
Last Comment
Vijay

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Scott Pletcher

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Pawan Kumar

Shrinking will increase fragmentation. Data that is moved to shrink a file can be scattered to any available location in the file. This causes index fragmentation and can slow the performance of queries that search a range of the index. To eliminate the fragmentation, consider rebuilding the indexes on the file after shrinking.

From Microsoft - https://technet.microsoft.com/en-us/library/ms190757%28v=sql.110%29.aspx?f=255&MSPPError=-2147217396
Scott Pletcher

Btw, you need only one log file.  Multiple log files would only be used sequentially anyway.  Log file(s) don't affect data file allocation in any way at all.
Vijay

ASKER
Hi Pawan,

You are right. But we are not shrinking data file.

We are only planning to shring .ldf filse?
Your help has saved me hundreds of hours of internet surfing.
fblack61
Pawan Kumar

>>We are only planning to shring .ldf filse?
For ldf there should not be any fragmentation issue. The above comment is for mdf files.
Vijay

ASKER
Excellent answer Scott.