Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 7th, 2004, 08:37 PM
Registered User
 
Join Date: Jul 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default del+ins as opposed to update

 Hi,

I am working on an application which will have a db for appointment management.
The application if defined to be compatabile with any db(SQL Server,mySQl,postgres)
Presently in the design stages what we are most concerned about is efficiency,and soem of us were had experienced slowness with ORacle daatabases doign updates on large databases.

So instead of and UPDATE would a DELETE and INSERT be more efficent???

Now the problems comes when we have auto indexed records.The solution some of us came up with was to instead have a meta table which would store the lookup id of the autonumbered field.

However,I would still be intersted in knowign if this idea of using DELETE+INSERT for an UPDATE would increase efficiency ??? Has anyone come across this issue before??


 
Old July 7th, 2004, 09:08 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I would be very surprised if a DELETE/INSERT combo query were better than a single UPDATE query. When you DELETE and INSERT, the db system has to deal with index maintenance where as an UPDATE just updates data (granted, if you update an indexed field then the db still needs to handle indexes).

When you speak of slowness with oracle, what kind of updates are you referring to? An update on a single record? Or an update on multiple records?
 
Old July 8th, 2004, 06:49 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

An update of a data row in SQL Server is sometimes the equivalent of a delete and insert operation. But, if you don't change the clustered index key, and you don't change the size of any variable length data (e.g. varchar columns), then the update can occur in place.

If the clustered index key does not change in the update, then no indexes need to be changed (unless affected by the update, of course), regardless of whether the update was in place or not.

If the update cannot be done in place, then the row may still be stored in its current page, if there is enough room (see Fill Factor).

Doing your own delete and add would be way slower.

If you are making design decisions based on your (mis)conceptions of the way SQL Server handles its internals, or based on the way you know or think it is done in other products, I strongly suggest you do yourself a favor and get a copy of the book "Inside Microsoft SQL Server 2000", by Kalen Delaney. It's an excellent book and it discusses, sometimes in excruciating detail, the internals of SQL Server and how it works.


Jeff Mason
Custom Apps, Inc.
www.custom-apps.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Type:VBScript compilation(0x800A0401)IN DEL zedekiah BOOK: Beginning ASP 3.0 1 June 6th, 2008 11:08 PM
Add,update,del data- Best practice? Renu Classic ASP Databases 3 August 9th, 2004 09:58 PM
How to block Alt+Ctrl+Del sagarkoirala VB How-To 0 August 8th, 2003 12:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.