SQL Server Shrink hurting performance?

s_sykes used Ask the Experts™
I inherited a SQL server and the performance is not the best.  I noticed that the front end app that uses the database moves data between several tables when it starts each morning and then runs a shrink on the database.  It looks like there is a weekly maintenance task that rebuilds indexes and then runs a shrink on the weekend as well!

When I looked at the indexes today, there are many that are heavily fragmented.  Autogrowth is set to 1MB, unlimited.  I know this setup has been in place for a year or so.  The database is around 20GB.  Large chunks of data are moved in and out of the database regularly.

If I stop the shrink operations and rebuild the indexes, will that fix my problem?  Or is the database likely in a state where more drastic action is needed?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
lcohanDatabase Analyst

Which files of the database are shrinked?
IF only T-log than is not that bad but indeex if MDF data files are shrinked as well then indexes will be fragmented so AFTER the shrink you should run a REBUILD and SP_UPDATESTATS  instead of before the shrink.

You could read a lots of good advice here:

Distinguished Expert 2017
yes, shrinking database impacts performance if during the day the newly inserted data has to await the space allocation.

There is not enough info to answer your question.

Understanding databse use/functionality along with the app that uses it may provide reason ..

In a situation where there is a working table that one to limit the number of records to active ..
Which might be what the situation is where each morning the process goes through the working table and "archives" completed tasks to a historic table.

There are several ms example of a sp/task that can run and reorganize the index or rebuild on a per index/table basis based on index fragmentation.

Instead of shrinking, you shoukd check the file growth settings compared to the data being added.
I.e. If there is a need for space, if you set it too low it will hit performance since every third record a new space allocation is needed.
s_sykesIT Director


Yep - I did read that.  That's why I'm wondering of the database is completely messed up and need to be redone in some form to fix it.
Distinguished Expert 2017

First thing to try, disable the daily shrink or make sure auto shrink is not set. But monitor the growth.
Look at index fragmentation.

After shrink/allocate is not the issue, see if you could identify where the performance slowness is coming from, i.e. Specific queries/pages ... Then ......

You could use SQL tunning advisor to capture/analyze the operation and see what recomendations are made.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial