|
|
|
|
|
|
| Author |
Message |
Gregory Bond *nix forums beginner
Joined: 11 Apr 2005
Posts: 21
|
Posted: Mon Apr 04, 2005 10:41 pm Post subject:
sp_rename advice pls
|
|
|
We have an application that has a large, mostly read-only, table. This
table is created by bcp-ing in a bunch of data then doing some fairly
heavy duty SQL manipulation.
The kicker is the update has to happen while the app is still running,
and we have been having a fair bit of grief with app timeouts while this
table is updated.
So we are considering using sp_rename like this:
bcp data into table_new
sql to fix up all the odds and ends in table_new
begin transaction
sp_rename table, table_old
sp_rename table_new, table
end transaction
Does this sound like a good idea? Anything we should watch out for?
[There are no triggers, rules or stored procs that reference this table,
it's all done from ct-lib SQL. But it does have a number of somewhat
complex indexes.]
Will sp_rename work in a transaction like this? (We can live without the
transaction I suppose - better than the grief at the moment!) |
|
| Back to top |
|
 |
Anthony Mandic *nix forums Guru Wannabe
Joined: 05 Jul 2005
Posts: 164
|
Posted: Tue Apr 05, 2005 7:10 am Post subject:
Re: sp_rename advice pls
|
|
|
Gregory Bond wrote:
| Quote: |
We have an application that has a large, mostly read-only, table. This
table is created by bcp-ing in a bunch of data then doing some fairly
heavy duty SQL manipulation.
The kicker is the update has to happen while the app is still running,
and we have been having a fair bit of grief with app timeouts while this
table is updated.
So we are considering using sp_rename like this:
bcp data into table_new
sql to fix up all the odds and ends in table_new
begin transaction
sp_rename table, table_old
sp_rename table_new, table
end transaction
Does this sound like a good idea? Anything we should watch out for?
|
Since sp_rename is a system sproc, it may not like being
run within the scope of a transaction. Check its source
to confirm this.
The basic idea of a switchover is sound but the better way
to do it might be to create a table (empty, of course) that
just acts as a flag. The existance to the table tells the
app to not do any processing while the table exists. It
should loop and check every second or so. While the apps
stalls on this you rename the tables. So the process
becomes -
bcp in
create table foo ...
<app stalls while it checks>
sp_rename ...
sp_rename ...
drop table foo
<app continues>
Make sure the app doesn't check for the table too frequently.
If you are on Unix, as an alternative, you could signal the
app.
-am © 2005 |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Thu Jan 08, 2009 3:57 am | All times are GMT
|
|
Mortgages | Bankruptcy | Problem Mortgage | Mortgage | Credit Report
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|