Author |
Topic |
DeepSeed
Yak Posting Veteran
52 Posts |
Posted - 2011-03-15 : 16:51:18
|
Hello SQL TeamOur SQL database tends to stop responding from time to time. It gives timeout errors and the CPU maxes to 100%. We find that queries that used to take 1 second to complete now take 40 seconds to complete when the databases go into this mode.Then we run this command and the problem goes away for a bit.EXEC sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?', ' ', 80)"Which tells me that we have INDEX problems.So my question is this. Why are we having index problems and how can we keep the tables from needing to be re-indexed.If the answer is to run this command every day then there is a problem with that. When we run this command our database becomes essentially unavailable, it complains of locked tables and takes a very long time to respond while this is running. We have defined our database as being "always available" so we can't have daily maintenance periods. |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
DeepSeed
Yak Posting Veteran
52 Posts |
Posted - 2011-03-15 : 17:15:00
|
We are using SQL 2008 (sql 2005 on a few instances).So if I add this SP and run it, it will accomplish the same task but without causing the locking/performance issues we see when running REINDEX? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
DeepSeed
Yak Posting Veteran
52 Posts |
Posted - 2011-03-15 : 17:17:52
|
Sorry forgot to mention that, we are using Standard. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
DeepSeed
Yak Posting Veteran
52 Posts |
Posted - 2011-03-15 : 17:59:17
|
Ok, so with Standard my only real option is to use this command.EXEC sp_MSforeachtable @command1="print '?' ALTER INDEX ALL ON ? REBUILD WITH ONLINE = ON" |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
DeepSeed
Yak Posting Veteran
52 Posts |
Posted - 2011-03-15 : 18:40:30
|
Opps I meant REORGANIZE not REBUILD. Sorry! Is there something else wrong with this script, can I modify your script to work with SQL standard edition? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
DeepSeed
Yak Posting Veteran
52 Posts |
Posted - 2011-03-15 : 18:57:24
|
Ok, but it will run in OFFLINE mode in Standard edition? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
DeepSeed
Yak Posting Veteran
52 Posts |
Posted - 2011-03-15 : 19:01:30
|
Ahhh, ok thanks!! |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|