473,385 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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***********************@splwgREMOVETHISTOO.Com

Jul 23 '05 #1
6 2060
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****@sommarskog.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**********@wcc.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****@sommarskog.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
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...
3
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...
10
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...
2
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...
2
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...
23
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...
5
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...
7
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...
7
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.