February 17, 2023 at 10:47 am
Hi everybody,
we'd like to migrate one of your biggest databases. But before we could do this, we'd like to shrink the datafile, there are about 700 GB left, which will never be used.
We'd like to shrink, that we can size the new server a little bit smaler.
But, can I save time, if I remove the database from the aoag, before I start shrinking?
I know, if I shrink, I got a lot of fragmentation, but we had to save the disk space on the new system. We tryied so shrink, while the database was part of the aoag, but it happened nothing, we weren't able to shrink 30GB in 30 minutes.
Maybe someone can give me tips.
Thanks
Kind regards,
Andreas
February 17, 2023 at 4:30 pm
I can't help on AOAG because I've never had to use it. Once someone helps you figure that out, I can give you a very strong hint on how to defragment without ending up with a large amount of free space cause by the necessary REBUILDs.
As a bit of a sidebar, if you have large indexes that you need to rebuild on occasion, consider moving each one to its own separate file/filgroup and leave it there. The next time you need to rebuild it, create another new file/filegroup and do move using the "with drop existing" thing. Then drop the now empty file group and you won't have any large amounts of unwanted freespace in your database like you normally would. I simply refer to this method as a "Swap'n'Drop". It takes some custom coding but it is SO worth it for me especially when it comes to keeping the size down for test restores, necessary (and secure, to be sure) copies of prod, etc, etc.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply