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

  • 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

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

    ---------------------------------------------------------------------

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

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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

    ---------------------------------------------------------------------

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply