473,783 Members | 2,418 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL Server execution plans

I'm looking for assistance on a problem with SQL Server. We have a
database where a particular query returns about 3000 rows. This query
takes about 2 minutes on most machines, which is fine in this
situation. But on another machine (just one machine), it can run for
over 30 minutes and not return. I ran it in Query Analyzer and it was
returning about 70 rows every 45-90 seconds, which is completely
unacceptable.
(I'm a developer, not a DBA, so bear with me here.)
I ran an estimated execution plan for this database on each machine,
and the "good" one contains lots of parallelism stuff, in particular
the third box in from the left. The "bad" one contains a "Nested Loop"
at that position, and NO parallelism.
We don't know exactly when this started happening, but we DO know that
some security updates have been installed on this machine (it's at the
client location), and also SP1 for Office 2003.
So it looks like parallelism has been turned off by one of these fixes.
Where do we look for how to turn it back on? This is on SQL Server
2000 SP3.
Thanks for any help you might have for me!
Christine Wolak -- SPL WorldGroup --
ch************* **********@splw gREMOVETHISTOO. Com

Jul 23 '05 #1
6 2075
I don't think lack of parallelism is a concern. I think the nested
loop is more of concern. Ideally, the execution plan should show only
"index seeks" meaning MSSQL will perform a single pass on an index.
The nested loop means it will procedurally loop over something (look
for number of executes to see how many times it loops). I would run
DBCC SHOWCONTIG to see if your indexes are fragmented, assuming you
have indexes on that machine. I would also try running SP_UPDATESTATS
before executing the query.

Jul 23 '05 #2
Compare the indexes on the tables in each database, make sure they are
the same.

Jul 23 '05 #3
Christine Wolak (ca*****@gmail. com) writes:
I'm looking for assistance on a problem with SQL Server. We have a
database where a particular query returns about 3000 rows. This query
takes about 2 minutes on most machines, which is fine in this
situation. But on another machine (just one machine), it can run for
over 30 minutes and not return. I ran it in Query Analyzer and it was
returning about 70 rows every 45-90 seconds, which is completely
unacceptable.
(I'm a developer, not a DBA, so bear with me here.)
I ran an estimated execution plan for this database on each machine,
and the "good" one contains lots of parallelism stuff, in particular
the third box in from the left. The "bad" one contains a "Nested Loop"
at that position, and NO parallelism.
We don't know exactly when this started happening, but we DO know that
some security updates have been installed on this machine (it's at the
client location), and also SP1 for Office 2003.
So it looks like parallelism has been turned off by one of these fixes.
Where do we look for how to turn it back on? This is on SQL Server
2000 SP3.


Interesting. In many cases it's the other way round. The parallel plan
is bad, and the non-parallel plan is good.

I find it unlikely that the security fixes for Office would affect SQL
Server. Then again, Office on a machine that runs SQL Server?

Or do are we talking about the same server/database in both cases? Well,
whatever is one the client machines does not affect SQL Server at all.
I first wrote an answer based on the assumption that this happened on
two servers. But reading closer, it seems we are talking the same database.

The likely reason for a difference is connection settings. Run DBCC
USEROPTIONS in QA one the problematic client and on a client where
everything works fine, and compare. You can change connection settings
for QA under Tools->Options. Or simply issue SET commands.

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

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #4
How could connection settings on different clients create different
execution plans on the server?

Jul 23 '05 #5
Gary (ga**********@w cc.ml.com) writes:
How could connection settings on different clients create different
execution plans on the server?


CREATE TABLE #null(a int NULL)
go
INSERT #null(a) VALUES (NULL)
go
SET ANSI NULLS OFF
go
SELECT * FROM #null WHERE a = NULL
go
SET ANSI NULLS ON
go
SELECT * FROM #null WHERE a = NULL

And, yes, those are different plans. When ANSI_NULLS are ON (as it should
be), the optimizer can transform the query to a no-op, but for the other
case it may have to scan the table.

More generally, a execution plan is associated with a set of SET options,
and if a process does not match that setting, another plan will be used.

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

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #6
Thanks everyone for the assistance.
Regarding the questions about the server, this was a situation where I
take a single database backup file, restore it on machine A and machine
B, and the execution plans are different for the same query. Assume A
is bad and B is good. If I take a different backup file (same basic DB
just from a different date), and put it on A and B, I get the same
results. Meaning it's something about the MACHINE, and not something
about the database.

So, it turns out that I overlooked the most obvious answer to the
question, and that is that the bad machine actually had only one CPU!
So parallelism is not used. I never even checked for this because I
thought I already knew that it had two CPUs. My bad. They must have
been just barely sneaking in under the timeout value earlier, but the
extra month of data pushed it over the brink.

I did find the OPTION (maxdop 2) hint, and also OPTION (hash join),
which would help if I could actually use them!
Thanks again everyone.
Christine

Jul 23 '05 #7

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

Similar topics

18
10309
by: Robin Lawrie | last post by:
Hi again, another problem! I've moved from an Access database to SQL server and am now having trouble inserting dates and times into seperate fields. I'm using ASP and the code below to get the date and time, but my script is erroring. '-- Get login date and time cmdLoginDate = Date() cmdLoginTime = Time()
3
2488
by: James Walker | last post by:
Hi there - hoping someone can help me here! I have a database that has been underperforming on a number of queries recently - in a test environment they take only a few seconds, but on the live data they take up to a minute or so to run. This is using the same data. Every evening a copy of the live data is copied to a backup 'snapshot' database on the same server and also, on this copy the queries only take a second or so to run....
10
7302
by: JL | last post by:
To All, I have a SQL2KSP3a database(<1GB) running on a 4x3GB physical CPU with 4GB of ram. It is Windows Server 2003 with hyper-threading turn on. There are ~420 .Net users/cxns (fat client, no web/app servers) with connection pooling and ~1 trx/sec. The database growth is neglegeable and actually is not even relevent which I will explain in a minute. 99% of the trxs are from one SP that does a select. The resultsets are relatively...
2
2059
by: Jenny Zhang | last post by:
Hi, I am running OSDL-DBT3 test against PostgreSQL. I found performance difference between the runs even though the data and queries are the same. I tried to study this problem by getting execution plans at the beginning of each test. The following script gets execution plan for 22 queries, except query 15. i=1 while
2
2274
by: Jenny Zhang | last post by:
The osdl-dbt3 test starts with building and vacuuming the database. The execution plans were taken after the vacuuming. I did two tests with the same database parameters: 1. run two osdl-dbt3 runs on one box without rebooting the stystem. Though the execution plans are the same, the costs are different. The system status are different for the two runs, for example, some page cache are not released after the first one. Does that make...
23
14042
by: Nishant Saini | last post by:
Dear All, We have a database which contains many tables which have millions of records. When We attach the database with MS SQL Server 2005 Standard Edition Server and run some queries (having joins, filters etc.) then they take very long time to execute while when We execute same queries on Enterprise Edition then they run 10 times faster than on standard edition. Our database does not use any features which are present in Enterprise
5
10760
by: sqlgirl | last post by:
Hi, We are trying to solve a real puzzle. We have a stored procedure that exhibits *drastically* different execution times depending on how its executed. When run from QA, it can take as little as 3 seconds. When it is called from an Excel vba application, it can take up to 180 seconds. Although, at other times, it can take as little as 20 seconds from Excel.
7
1835
by: alexbf | last post by:
Hello, I have a stored procedure in SQL Server 2000. When I execute it through my .NET application (OleDbCommand), I can see (in SQL Profiler) that it takes 423 ms to complete. If I run the same exact query in Query Analyzer, it takes 216 ms (in SQL Profiler).
7
1779
by: Andres Rormoser | last post by:
I'm having a performance Issue with my Production SQL Server (2 x Xeon Dual-Core Woodcrest 1.6Ghz, 2GB RAM, IIS, SQL Server). In general the querys take much longer than the querys in my development server . For example a recursive UDF takes 20s in my development server and 2m in my production server (both with same users load) but my production server it's much hardware powerfull than the other server. I start monitoring an realized...
0
9643
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
9480
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
10313
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
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
9946
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...
0
5378
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
4044
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
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
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.