dbTalk Databases Forums  

sql reindex

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss sql reindex in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
benamis
 
Posts: n/a

Default sql reindex - 07-20-2005 , 10:19 AM






hi

maybe someone has a script which recreates the indexses on db?

i think the best way is to use

CREATE unique INDEX
WITH DROP_EXISTING

and the procedure sp_MSforeachtable

the problem is that i don't know how to "join" these 2 options as every
table has lots of indexses...

currently i use this:

exec sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?')"

but it is 2x less effective as "CREATE unique INDEX WITH DROP_EXISTING"


thanx

P.S. i am not too good in sql programing


Reply With Quote
  #2  
Old   
Andrew J. Kelly
 
Posts: n/a

Default Re: sql reindex - 07-20-2005 , 12:12 PM






What do you mean by 2x less effective? Did you have plenty of free space in
the database before you issued the DBCC DBREINDEX? If not then the files
would have had to grow, probably multiple times. This can be a real
performance issue and you should always ensure you have plenty of free space
at all times. Never shrink the files after you do a reindex or you just
waste the effort in the first place. You can not recreate the indexes in
the manor you indicate and should not try. DBCC DBREINDEX is usually the
best method to deal with reindexing all the indexes on a table.

--
Andrew J. Kelly SQL MVP


"benamis" <nera (AT) meilo (DOT) lt> wrote

Quote:
hi

maybe someone has a script which recreates the indexses on db?

i think the best way is to use

CREATE unique INDEX
WITH DROP_EXISTING

and the procedure sp_MSforeachtable

the problem is that i don't know how to "join" these 2 options as every
table has lots of indexses...

currently i use this:

exec sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?')"

but it is 2x less effective as "CREATE unique INDEX WITH DROP_EXISTING"


thanx

P.S. i am not too good in sql programing




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.