Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Could use some help with Maintenance

Author  Topic 

The_Hoff
Starting Member

6 Posts

Posted - 2009-04-14 : 11:36:31
I have just became the new DBA and am now in the process of making a maintenance schedule (hasn’t been done in 2 years apparently). I have only one question at this time (though many will follow). I am under the impression that you have to detach the DB in order to perform the rebuild. Though I do know there is the online feature now but I do not know if that will encompass everything. So pretty much I am asking, Must I detach the DB in order to run a full rebuild and will an online rebuild cover all the bases?

-Phil

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2009-04-14 : 11:55:36
No, you do not need to detach the DB for the rebuild, offline just means that the index will not be available while the command is being run. Please read BOL before doing this, under ALTER INDEX
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-04-14 : 13:26:43
What edition of SQL Server are you using?

You can't rebuild an index with the database detached anyway, so even if you had tried, it wouldn't have worked.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

The_Hoff
Starting Member

6 Posts

Posted - 2009-04-14 : 13:31:23
we are using sql enterprise 2005

-Phil
Go to Top of Page

The_Hoff
Starting Member

6 Posts

Posted - 2009-04-14 : 13:39:08
i had no i idea that you could not rebuild on a detached database, as i said i have been "thrown" into this large tast of being not only a DBA but also DRA. i have a maintenance schedule made, and from what i have read seems to be a little much, it follows like this:
Backs every day (Diff and Trans)and Full w/ a Trans on Sundays

Mon: Update Stat
Tues: Reorganize
Wed: Update Stat w/ DB Integrity Check
Thurs: Reorganize
Fri: Update Stat
Sat: Update Stat
Sun: Online Rebuild w/ DB Integrity Check

Also we plan on performing an Offline Rebuild Quarterly
Also with periodicly check if we must shrink DB which will probably turn into a quarterly thing


-Phil
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-04-14 : 17:04:54
Here is what my environments looks like: http://weblogs.sqlteam.com/tarad/archive/2008/06/30/SQL-Server-jobs-on-production-instances.aspx

Note that this is setup on mission critical databases with very high SLAs.

My isp_ALTER_INDEX, rebuilds indexes, intelligently decides which indexes to rebuild and whether or not it can do them ONLINE or not. I'd suggest using this stored procedure rather than what is in Books Online or what is available in the maintenance plans as those do not always do the right thing.

Do not shrink the database. It is pointless to do this if the database needs the space. You will only cause issues by shrinking it.

Also, you need to perform transaction log backups on a much more frequent basis than just once a day.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

The_Hoff
Starting Member

6 Posts

Posted - 2009-04-15 : 05:07:50
with your script, you have graciously provided, when it rebuilds the database and if it has to take it offline what kind of effect will we see when it comes to users? we are currently running VMs from sql along with Solarwinds, now taking those offline could bring down not only multiple servers but also all monitoring abilities we have of or extensive network, or am i looking at this wrong?

-Phil
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-04-15 : 13:59:40
You are misunderstanding what offline vs. online means in regards to the index with ALTER INDEX. Check Books Online for details.

It is not referring to taking the database offline.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

The_Hoff
Starting Member

6 Posts

Posted - 2009-04-15 : 16:00:53
i get that offline does not mean detach, i understand that it will still be there, i just want to know if an offline rebuild will affect a server that is built off the database. we use virtuak machines and they must have sql inorder to operate no sql no server.

-Phil
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-04-15 : 16:22:52
Here is what OFFLINE means in regards to ALTER INDEX:

quote:

Table locks are applied for the duration of the index operation. An offline index operation that creates, rebuilds, or drops a clustered index, or rebuilds or drops a nonclustered index, acquires a Schema modification (Sch-M) lock on the table. This prevents all user access to the underlying table for the duration of the operation.



The above quote means that queries will have to wait until the locks are removed before the query can complete. Depending upon the timeout value in the application and how long it remains offline will determine what affect it has on the application that is connecting to the database.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-04-15 : 16:25:20
You are using Enterprise Edition, so the ONLINE option can be used in most cases.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

The_Hoff
Starting Member

6 Posts

Posted - 2009-04-16 : 05:53:03
Originally i became angry with the response i received, but after thinking about my posts, i realized i was not direct with explaining what i knew and what my issues were. i do know that scripts are the best way, but for now we are just formulating something basic to start out with (until we can expand our SQL knowledge). I was given a 3 day deadline to come up some sort of beginning maintenance, and this was the fastest way. I will be back with more questions (hopefully more direct and intelligent questions) once i start digging deeper into sql. thank you for your time tkizer and your brief presence RickD.

-Phil
Go to Top of Page
   

- Advertisement -