Link to home
Start Free TrialLog in
Avatar of zephyr_hex (Megan)
zephyr_hex (Megan)Flag for United States of America

asked on

Do i need to defrag or rebuild indexes on a database where data in the tables is deleted daily?

i have a database that imports data from our ERP system on a daily basis.  before the import, each table is "cleared" with a "delete from" statement.

do i need to defrag or rebuild indexes on this database?

i have another database that does the same thing as above, but it imports every 30min throughout the work day.

same question... do i need to defrag or rebuild indexes?  or does the DELETE FROM take care of that?

i ran the script here:
http://www.mssqltips.com/tip.asp?tip=1165
that shows which indexes to defrag.  but the numbers i see in the results seem really low...
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zephyr_hex (Megan)

ASKER

angelIII:
when you say efficient, are you meaning that SQL will handle the process faster if i do it that way?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>when you say efficient, are you meaning that SQL will handle the process faster if i do it that way?
yes. once you think about it, it shall be obvious:

* drop index (will be very quick)
* truncate table (will be very quick)
* fill data into table (will be as quick as possible, as no indexes are there to be maintained)
* create index (will be quicker than maintaining it while inserting all the data)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
these are great comments.  thanks