473,809 Members | 2,610 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Different UPDATE behaviors across servers

Hi!

I have a stored procedure that takes 22 minutes to run in one
environment, that only takes 1 sec or so to run in another
environment. Here is the exact situation:

Database 1 on Server 1 vs. Database 2 on Server 2 - the data is
exactly the same, and the tables and index structures are exactly the
same. Implicit transactions are turned off on both databases.

Stored procedure:

BEGIN TRANSACTION

--step 1
TRUNCATE myTable

--step 2
INSERT INTO myTable VALUES ('myValues')

--step 3
UPDATE a
SET rating=AVG(some Values)
FROM myTable a
JOIN otherTable b
ON a.column1=b.col umn1
GROUP BY someColumns

COMMIT TRANSACTION

The update statement on the problem server is the only step that takes
forever. While it is running, I don't see anything that could be
blocking the statement. I used the following queries to determine if
there was another process blocking it:

select spid AS Blocked, blocked AS Blocking, waittime, cmd, substring
(nt_username, 1, 15), dbid, physical_io,
substring(hostn ame, 1, 15), program_name, lastwaittype, waitresource,
memusage
from master.dbo.sysp rocesses where blocked <0
order by waittime desc

select dbid, name from sysdatabases where dbid in (select dbid from
master.dbo.sysp rocesses where blocked <0)

select spid AS BlockingFromAbo ve, blocked AS TrueBlockingQue ry,
waittime, cmd, substring (nt_username, 1, 15), dbid, physical_io,
substring(hostn ame, 1, 15), program_name, lastwaittype, waitresource,
memusage
from master.dbo.sysp rocesses where spid in (select blocked from
master.dbo.sysp rocesses where blocked <0)
order by waittime desc

When I change the UPDATE statement to a SELECT, it still takes longer
than it does on the test server (1 min 35 sec vs. several
milliseconds).

What could be causing the UPDATE to take forever on one server/
database, and run without a problem on another?

I am at a loss! Any help would be greatly appreciated.

Apr 24 '07 #1
1 2207
Dmitri (ni*********@gm ail.com) writes:
I have a stored procedure that takes 22 minutes to run in one
environment, that only takes 1 sec or so to run in another
environment. Here is the exact situation:

Database 1 on Server 1 vs. Database 2 on Server 2 - the data is
exactly the same, and the tables and index structures are exactly the
same. Implicit transactions are turned off on both databases.
Apparently the query plans are different. This could be because there
are differences in statistics between the databases. Fragmentation
could also matter. I would recommend that you run DBCC DBREINDEX on
the tables in both environments. If you are lucky, the query runs
quickly in both databases. If you are less lucky, the query will now
run slowly in both databases.

If the machines has a different number of processors, this could also
matter. Maybe one machine is a single-CPU machine, whereas the other
is an 8-way box, so there is a parallel plan on server and a non-parallel
plan on the other. Parallel plans are sometimes really amazing -
either amazingly fast or amazingly slow.
--step 3
UPDATE a
SET rating=AVG(some Values)
FROM myTable a
JOIN otherTable b
ON a.column1=b.col umn1
GROUP BY someColumns
Not that it matters for the discussion since I don't see the table
definition and the indexes, but this syntax is not legal.


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

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Apr 24 '07 #2

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

Similar topics

1
6225
by: Meghna | last post by:
Hi, I was wondering if some one would be able to help me with this. I am trying to share a session across two servers and I seem to be experiencing some problems. I was wondering if anybody has already tried something like this before and hence be able to provide some guidance in this regard. Any suggestions, pointers or redirections to useful links is welcome. Thanks in advance for your help,
137
7209
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very pragmatic - 3) I usually move forward when I get the gut feeling I am correct - 4) Most likely because of 1), I usually do not manage to fully explain 3) when it comes true. - 5) I have developed for many years (>18) in many different environments,...
1
1511
by: Stephanie Stowe | last post by:
Hi. I have a problem that I am trying to troubleshoot on a client's production (*sigh*) servers. On one server, we will call web2 all works well. On another server, we will call web1, the client receives and error. Through debugging, I have isolated this client-side code: // send SOAP request var oHTTPPost = new ActiveXObject(XML_HTTP_OBJ); oHTTPPost.Open("POST", sURL, false); oHTTPPost.setRequestHeader("Content-type", "text/xml");...
2
1364
by: yawnmoth | last post by:
Say I had the following script: <? echo $_SERVER; ?> Lets call this script test.php. On some severs, accessing /test.php/foobar will yield in /test.php/foobar being displayed while on others, it'll result in /test.php being displayed. I can't seem to find anything that all the servers that do display it or all the
15
5817
by: Neo | last post by:
Hello All, I found that ASP.net website only accepts code withing site directory. This creates big hurdle in shairng code. How to share code between two websites, like the way share between two non-website code? -Pravin
2
2377
by: DanWeaver | last post by:
I have a page where layout of buttons and listboxes etc is important - I would like to make use of Ajax Update panel to asynchronously update various part of the page- in Vis studio whenever I use an Update panel I then lose all control of the layout of the elemts within the panel. I also dont seem to be apble to have a vs 'panel' within an update panel and this means I cant use the rounded corners functionality available with Ajax....
10
4738
by: David | last post by:
I am trying to get this straight in my head so I can implement. I wrote a small utility some time ago in c# that utilized a handful of threads. That scenario was one main thread manually spawning a handfull of worker threads, then waiting for all of them to complete before moving on. I believe I used array of ManualResetEvents and the WaitAll() method to do this. All the worker threads used a shared object (a common place to collect...
0
9856
NeoPa
by: NeoPa | last post by:
Introduction : I have come across a problem, on a number of occasions, where PCs under my control fail to load new updates successfully. This is true whether they are attempting to apply via the Automatic Updates facility built into the OS or whether accessing the MS Update site directly. Reason : The problem is often associated with DLL files not being correctly set up for some reason. Most of the suggested fixes involve registering a...
7
3341
by: Mel | last post by:
I have an update panel that has the UpdateMode set to "Conditional". When I call UpdatePanel1.Update() in the VB code it does not work in FireFox. It works just fine in Internet Explorer 6.0. Any ideas on how to fix it so it works in FireFox 2.0.0.14?
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10120
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7662
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.