Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What maintenance actions can't be done when log shipping is set up?

Status
Not open for further replies.

jsteph

Technical User
Oct 24, 2002
2,562
0
0
US
Hi all,
I had another thread that I didn't want to overload with too many questions, so here is another log-shipping question:
Can I perform dbcc ShrinkFile on either database in a log shipping setup without having to backup/restore and restart the log shipping? If not, are there any other common maintenance tasks (aside from backup of course) that I am restricted from doing on the primary database when I have log shipping set up? We're undergoing this for the first time and would like to know the gotcha's and all the little things that we may not be able to do anymore when we have the remote site set up and are depending on them to be perfectly in sync.
Thanks very much,
--Jim
 
You can shrink the source but make sure you use the notruncate option as truncating will break log shipping. The shrink will be shipped over to the destination so only needs to be done on the source.

Not sure what would happen if you only shrunk the destination or did it first so I wouldn't try it.

Personally I would never class dbccc shrinkfile as a maint task and should only ever be used as a last resort or "get out of jail card". Look at why you are needing to shrink and resolve the space issues instead.

Biglebowskis Razor - with all things being equal if you still can't find the answer have a shave and go down the pub.
 
thedude,
Thanks for the response, I'm interested in the point about dbcc shrinkfile. We have a situation where we have a massive usertable for tracing, and it gets used infrequently, but when it does it grows huge, and deleting (or truncating) its records doesn't release the space--the .mdf file stays in its bloated state.

This is more common on our dev onstances which have limited disk space (and aren't in a log-shipped situation)--but we have found ourselves having to do this in prod during off hours. So is it something in the way we're deleting the records that causes the .mdf not to go back to its original size? So in our case we don't always assume that when the file grows that huge it simply must stay that big, even assuming future growth may fill that space eventually.

I get that using a temp file like that in production is not a best practice, but from an academic standpoint, is the situation I described (a table that grows huge and then is truncated) something that would grow the .mdf and not automatically shrink it, and a valid case where one would need dbcc shrinkfile?
Thanks,
--Jim
 
JSteph,

Try DBCC SHRINKFILE with the TRUNCATEONLY option. If you do not use this option you must rebuild the indexes, which most likely will cause the DB to grow again.

MCP SQL Server 2000, MCTS SQL Server 2005, MCTS SQL Server 2008 (DBD, DBA)
 
Best thing to do in that scenario is preallocate the DB to the max you will utilise, if the table is used infrequently and truncated it still won't shrink the table back to its "empty" size again. Dbcc shrinkfile actually messes up the indexes more than not shrinking.

Biglebowskis Razor - with all things being equal if you still can't find the answer have a shave and go down the pub.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top