473,386 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

sp_attachdb time varies

Ray
Every night we use sp_attachdb to attach a 1TB database to our data
warehouse server. Each night we kill off all nonsystem related spids, set
all the other databases to DBO only and then attach. The attach seems to
take between 4 minutes to an hour. With an idle server and filegroup sizes
that have not grown what could be causing the variance? The number of
transactions to rollback or forward doesn't seem to have an impact. The log
indicates that the attach is spending almost all its time in phase 2.
Anyone know exactly what happens in phase 2?

Books online and reading the sp_attachdb proc weren't much help.
sp_attachdb is simply a derived call to create database ... for attach.

Any insight is appreciated.

Thanks,
Ray
Jul 23 '05 #1
5 2868
Ray (so*****@nowhere.com) writes:
Every night we use sp_attachdb to attach a 1TB database to our data
warehouse server. Each night we kill off all nonsystem related spids,
set all the other databases to DBO only and then attach. The attach
seems to take between 4 minutes to an hour. With an idle server and
filegroup sizes that have not grown what could be causing the variance?
The number of transactions to rollback or forward doesn't seem to have
an impact. The log indicates that the attach is spending almost all its
time in phase 2. Anyone know exactly what happens in phase 2?

Books online and reading the sp_attachdb proc weren't much help.
sp_attachdb is simply a derived call to create database ... for attach.


I gladly admit that I don't have very many ideas, so I forwarded the
question to our internal MVP forum where people from Microsoft also
attend.

What does your @@version say?
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #2
Ray
We are currently at build 997 but the issue existed under 789 as well.

Thanks,
Ray

"Erland Sommarskog" <es****@sommarskog.se> wrote in message
news:Xn**********************@127.0.0.1...
Ray (so*****@nowhere.com) writes:
Every night we use sp_attachdb to attach a 1TB database to our data
warehouse server. Each night we kill off all nonsystem related spids,
set all the other databases to DBO only and then attach. The attach
seems to take between 4 minutes to an hour. With an idle server and
filegroup sizes that have not grown what could be causing the variance?
The number of transactions to rollback or forward doesn't seem to have
an impact. The log indicates that the attach is spending almost all its
time in phase 2. Anyone know exactly what happens in phase 2?

Books online and reading the sp_attachdb proc weren't much help.
sp_attachdb is simply a derived call to create database ... for attach.


I gladly admit that I don't have very many ideas, so I forwarded the
question to our internal MVP forum where people from Microsoft also
attend.

What does your @@version say?
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Jul 23 '05 #3
Ray (so*****@nowhere.com) writes:
We are currently at build 997 but the issue existed under 789 as well.


Thanks! Then I know, if someone asks me!

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #4
"Ray" <so*****@nowhere.com> writes:
Every night we use sp_attachdb to attach a 1TB database to our data
warehouse server. Each night we kill off all nonsystem related spids, set
all the other databases to DBO only and then attach. The attach seems to
take between 4 minutes to an hour. With an idle server and filegroup sizes
that have not grown what could be causing the variance? The number of
transactions to rollback or forward doesn't seem to have an impact. The log
indicates that the attach is spending almost all its time in phase 2.
Anyone know exactly what happens in phase 2?

Books online and reading the sp_attachdb proc weren't much help.
sp_attachdb is simply a derived call to create database ... for attach.

Any insight is appreciated.


I have now gotten an answer from of the SQL Server devs. He said:

Phase 2 is REDO recovery and its length is going to be largely driven by
how> far back in the log the last checkpoint was. If they did a proper
sp_detach_db or ALTER DATABASE SET OFFLINE there should be nothing to REDO.
If they can't do this for some reason, they should at least attempt an
explicit CHECKPOINT on the database before the files are copied/moved/split
for their attach.
Does that give you an idea of how you should approach the problem?
--
Erland Sommarskog, Stockholm, es****@sommarskog.se

Jul 23 '05 #5
Ray
Yes. That really narrows it down. The source system never really stops.
They just snap it via the SAN so there are usually a few transactions (about
5 on average) to rollback and 3 to 5 thousand to roll forward. I'll see
what their checkpoint interval is and if they can implement an explict
checkpoint before the hot split.

Thanks,
Ray
"Erland Sommarskog" <es****@sommarskog.se> wrote in message
news:d1**********@green.tninet.se...
"Ray" <so*****@nowhere.com> writes:
Every night we use sp_attachdb to attach a 1TB database to our data
warehouse server. Each night we kill off all nonsystem related spids, set
all the other databases to DBO only and then attach. The attach seems to
take between 4 minutes to an hour. With an idle server and filegroup
sizes
that have not grown what could be causing the variance? The number of
transactions to rollback or forward doesn't seem to have an impact. The
log
indicates that the attach is spending almost all its time in phase 2.
Anyone know exactly what happens in phase 2?

Books online and reading the sp_attachdb proc weren't much help.
sp_attachdb is simply a derived call to create database ... for attach.

Any insight is appreciated.


I have now gotten an answer from of the SQL Server devs. He said:

Phase 2 is REDO recovery and its length is going to be largely driven by
how> far back in the log the last checkpoint was. If they did a proper
sp_detach_db or ALTER DATABASE SET OFFLINE there should be nothing to
REDO.
If they can't do this for some reason, they should at least attempt an
explicit CHECKPOINT on the database before the files are
copied/moved/split
for their attach.
Does that give you an idea of how you should approach the problem?
--
Erland Sommarskog, Stockholm, es****@sommarskog.se

Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Monty | last post by:
Let's say you provide an online service from 7:00AM to 6:00PM Eastern Time (daylight time in the summer). Is there way of showing these hours of availability on a web page in the user's local...
6
by: vee_kay | last post by:
Ihave a written aprogram in C which implements _beginthread(to create a thread) and _endthread(to end a thread).The program need to write a string of date n time to a file for each succesful thread...
8
by: peterbe | last post by:
What's the difference between time.clock() and time.time() (and please don't say clock() is the CPU clock and time() is the actual time because that doesn't help me at all :) I'm trying to...
4
by: Andy Leszczynski | last post by:
Python 2.2/Unix >>time.strftime("%T") '22:12:15' >>time.strftime("%X") '22:12:17' Python 2.3/Windows >>time.strftime("%X")
5
by: Erich Schreiber | last post by:
In the Python Library Reference the explanation of the time.sleep() function reads amongst others: > The actual suspension time may be less than that requested because > any caught signal will...
17
by: Eric Lindsay | last post by:
Is learning to write CSS a better use of time than finding and using a package that produces complete web pages? I've moved to a new platform (Macintosh), taking with me about 400 personal web...
4
by: Wanhua Yi | last post by:
Hi all, anybody out there with experience in using EMC's Time Finder Software and DB2 UDB EEE on AIX ? Especially in using BCV for Backup ? Any white papers ?
1
by: Drew | last post by:
Is there a way to check if it is daylight savings or not via c#? I have heard you can use System.Globalization? Thanks - Drew
2
by: Al | last post by:
Hi Is it a function to convert time to and from military time? Thanks
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.