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


Export Import entire database (or best method to accomplish this)


Export Import entire database (or best method to accomplish this)

Author
Message
ken def
ken def
Forum Newbie
Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)

Group: General Forum Members
Points: 8 Visits: 48
Hi
I need to clean up a database. Main reason: datafiles have grossly disparate sizes. I'd like to export entire database (or some other meaningful method), resize and add datafiles of same size, re-import the data. What is the best way to accomplish this?

Further explanation of problem: When this database was originally created, there was one datafile. Over time, it grew quite large. Upon a subsequent upgrade,other datafiles were added, much smaller than the original datafile. As a result, considering the way MSSQL uses an algorithm to write data to datafiles, the data is not being distributed to the various datafiles in an equitable way. Hence, one datafile is very big and VERY hot. I'd like to redistribute the data to the various datafiles, and resize them equally so that the MSSQL algorithm would then evenly distribute data to ALL the datafiles.

Thanks for any help you can offer.
kd
george sibbald
george sibbald
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24300 Visits: 13698
SQL will use a proportional fill algorithm across the data files (in the same filegroup) to try and keep the amount of free space in each file the same. If your original file is still the hotspot this suggests this file is a lot emptier.

Do you have the space to increase the size of the newer files? Perhaps do that and shrink the original to remove some of the free space, then rebuild your indexes?

You will need an outage anyway so no need to move all the data out first (just take a backup)

---------------------------------------------------------------------
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (212K reputation)SSC Guru (212K reputation)SSC Guru (212K reputation)SSC Guru (212K reputation)SSC Guru (212K reputation)SSC Guru (212K reputation)SSC Guru (212K reputation)SSC Guru (212K reputation)

Group: General Forum Members
Points: 212285 Visits: 41977
ken def (10/19/2013)
Hi
I need to clean up a database. Main reason: datafiles have grossly disparate sizes. I'd like to export entire database (or some other meaningful method), resize and add datafiles of same size, re-import the data. What is the best way to accomplish this?

Further explanation of problem: When this database was originally created, there was one datafile. Over time, it grew quite large. Upon a subsequent upgrade,other datafiles were added, much smaller than the original datafile. As a result, considering the way MSSQL uses an algorithm to write data to datafiles, the data is not being distributed to the various datafiles in an equitable way. Hence, one datafile is very big and VERY hot. I'd like to redistribute the data to the various datafiles, and resize them equally so that the MSSQL algorithm would then evenly distribute data to ALL the datafiles.

Thanks for any help you can offer.
kd


Are the datafiles in the same filegroup or not?

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
ken def
ken def
Forum Newbie
Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)

Group: General Forum Members
Points: 8 Visits: 48
Yes, they are all in the same file group.
And When I say "hot", because the very large datafile holds so much of the data, many more reads are targeted against that datafile than any of the others.
george sibbald
george sibbald
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24300 Visits: 13698
aah, thats a different problem to the one I thought you were originally describing.

You need to bring the smaller datafiles up to the size of the original as much as possible. If space prevents this and these files are very small, get a drive that allows you to create new files of a decent size, shrink the small files with the emptyfile option to empty them, then drop them.

at the end rebuild the clustered indexes on the tables in the filegroup and SQL will attempt to spread the data between the datafiles.

I see no need at all to remove all your data from the database and reload it but you will need an outage and back the database up first.

If you can restore the database to a test server first to practice the task, script it up and get timings.

---------------------------------------------------------------------
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