niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Sybase
sp_rename advice pls
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
Author Message
Gregory Bond
*nix forums beginner


Joined: 11 Apr 2005
Posts: 21

PostPosted: Mon Apr 04, 2005 10:41 pm    Post subject: sp_rename advice pls Reply with 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?

[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

PostPosted: Tue Apr 05, 2005 7:10 am    Post subject: Re: sp_rename advice pls Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
The time now is Thu Jan 08, 2009 3:57 am | All times are GMT
navigation Forum index » Databases » Sybase
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Looking for advice on my company's postfix config Steve Scaffidi Postfix 8 Wed Jul 19, 2006 8:32 pm
No new posts relayclients control file patch advice Tim O'Donovan Qmail 10 Wed Jul 19, 2006 1:11 pm
No new posts Advice on deleting images from server using PHP Frankie PHP 16 Wed Jul 12, 2006 6:36 pm
No new posts Advice for Python Reporting Tool rwboley python 2 Wed Jul 12, 2006 5:44 pm
No new posts general advice on parameters mr_scary Postfix 1 Tue Jul 11, 2006 11:17 pm

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
[ Time: 0.1978s ][ Queries: 16 (0.1266s) ][ GZIP on - Debug on ]