Daily Database Refresh

  • Each day we import data from our mainframe into a SQL Server database. The previous days data is cleared out prior to running the import; the database size is roughtly 1.5 GB. Should I run dbcc reindex to increase the performance of the import.

    Thanks,

    Dave

  • drodriguez (7/31/2008)


    Each day we import data from our mainframe into a SQL Server database. The previous days data is cleared out prior to running the import; the database size is roughtly 1.5 GB. Should I run dbcc reindex to increase the performance of the import.

    Thanks,

    Dave

    How do you import the data?

    One way of doing this is:

    1) Disable all non-clustered indexes

    2) Truncate destination tables

    3) Import data

    4) Rebuild all indexes

    If you perform the above, no need to reindex since you are rebuilding and no need to update statistics either.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • Do you delete the indexes to disable a nonclustered index? Also, do you truncate a table by shrinking the database?

  • Rebuilding an index means dropping and recreating the index.

    You can truncate the tables using Truncate table

    You dont have to shrink the database and it will grow anyway when you load the data.

    Also make sure before you truncate the table keep the database is simple recovery mode. It will save some space. If you are critical about the data you are going to move in, make it full recovery mode again and take a backup.

    Finally, write a script (or multiple scripts) to do the tasks and execute them in order

    Jobs are handy for this type of tasks. You can schdule them, or execute whenever you want.

    Cheers,
    Prithiviraj Kulasingham

    http://preethiviraj.blogspot.com/

  • No and No 🙂

    You disable the indexes by issuing the command: ALTER INDEX indexname ON table DISABLE;

    You truncate a table using: TRUNCATE TABLE table;

    Now, if you have foreign key relationships defined - you won't be able to truncate the table and will need to delete the data (DELETE FROM table).

    To rebuild the indexes after the load, you issue: ALTER INDEX ALL ON table REBUILD;

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

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

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