473,508 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL 2005 Optimizer not optimizing

Hello

has anybody else noticed

I have queries that SQL 2000 optimizes correctly and they run very
fast

Yet SQL 2005 keeps using a dumb query plan and queries run very slow

The problem seems to stem from the assumption that data in a derived
table / subquery will not stay the same for different output rows

So the query is pointlessly re-evaluating the derived table again and
again
The same problem is also affecting subqueries

(This is how msaccess works - but that is not a real database server)

I have experimented with TABLOCKX but the optimizer still seems to
think data can change between rows

Am I missing something?

I am manually optimizing badly affected queries by rewriting them as
stored procedures with temporary tables
but that is like going back in time 20 years

The whole point in the optimizer is that it should find the most
intelligent way to return the results

John
Oct 13 '08 #1
5 2869
Covering the most basic issue first, have you updated statistics since
the conversion?

Roy Harvey
Beacon Falls, CT

On Mon, 13 Oct 2008 08:43:59 -0700 (PDT), John Rivers
<fi*****@btinternet.comwrote:
>Hello

has anybody else noticed

I have queries that SQL 2000 optimizes correctly and they run very
fast

Yet SQL 2005 keeps using a dumb query plan and queries run very slow

The problem seems to stem from the assumption that data in a derived
table / subquery will not stay the same for different output rows

So the query is pointlessly re-evaluating the derived table again and
again
The same problem is also affecting subqueries

(This is how msaccess works - but that is not a real database server)

I have experimented with TABLOCKX but the optimizer still seems to
think data can change between rows

Am I missing something?

I am manually optimizing badly affected queries by rewriting them as
stored procedures with temporary tables
but that is like going back in time 20 years

The whole point in the optimizer is that it should find the most
intelligent way to return the results

John
Oct 13 '08 #2
Yes
Oct 13 '08 #3
On Mon, 13 Oct 2008 11:24:38 -0700 (PDT), John Rivers
<fi*****@btinternet.comwrote:
>Yes
Every time there are major upgrades to the optimizer, there are at
least a few regressions where the execution plans are worse than
before. So far that has been the case with every upgrade, and it
doesn't seem likely to change.

I have found that the only recourse is to look at the queries with a
fresh eye and rewrite them, as you are already doing. From the sort
of problem you are reporting I suggest taking one of your problem
queries and posting it, with DDL so we know what the tables look like,
and explaining the performance problem. There are some sharp people
here and one might have an idea that is less work that the stored
procedures you are changing to now. You probably want to start a new
thread for that.

Roy Harvey
Beacon Falls, CT
Oct 13 '08 #4
On Mon, 13 Oct 2008 14:46:00 -0400, "Roy Harvey (SQL Server MVP)"
<ro********@snet.netwrote:
>From the sort
of problem you are reporting I suggest taking one of your problem
queries and posting it, with DDL so we know what the tables look like,
and explaining the performance problem. There are some sharp people
here and one might have an idea that is less work that the stored
procedures you are changing to now. You probably want to start a new
thread for that.
Also, I think the best group is microsoft.public.sqlserver.programming
for this sort of question.

Roy Harvey
Beacon Falls, CT
Oct 13 '08 #5
John Rivers (fi*****@btinternet.com) writes:
Yes
And you ran UPDATE STATISTICS WITH FULLSCAN?

Else I agree with Roy. With a new versions of SQL Server, there is
always some query that suddenly does not perform as well as it used to
do. There is never any magic pill to regain the performance but only
hard work.

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

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Oct 13 '08 #6

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

Similar topics

14
1945
by: Bupp Phillips | last post by:
I have a customer table that has the field CUSTOMER_ID as the primary key (cust_pkkey), the table has 102,834 records in it. The following select statement works fine: select * from customer...
21
1868
by: rkusenet | last post by:
Trolling before someone else does -) http://www.eweek.com/article2/0,1759,1776048,00.asp
9
2790
by: Andrea | last post by:
Hi, I've read the former postings but was not able to solve my problem: I have a Summary Table (or MQT as you like it) and the query optimizer does not seem to use the summary table. I run...
9
3752
by: Olaf Baeyens | last post by:
I am trying to understand the IL assembler created by C# but as far as I can see, there is no optimizing done by the C# compiler. Optimizing is done by the JIT, but it can only go so far. In C++...
2
1282
by: Brian Ross | last post by:
Hi, Would it be fair to say the following is an optimizer bug? --- Test.cpp --- #include <cstdio> using std::printf;
3
2217
by: datapro01 | last post by:
I am a DB2 DBA that has been asked to become familiar enough with SQL Server in order to become actively involved in its installation, implementation, and to review database backup/recovery...
7
1435
by: Shawn B. | last post by:
Greetings, I have a question. The framework SDK ships with a CS/VB.NET compiler. Does the Visual Studio 2005 IDE use these compilers or does the IDE have its own? This has me thinking. ...
2
3897
by: boa sema | last post by:
Way back when, and at least in version 7 IIRC, the query optimizer gave up when the where clause in a statement contained more than 4 search conditions. Does anyone know if such a limitation...
0
7233
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,...
0
7342
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,...
0
5650
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
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...
0
3215
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...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1570
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 ...
1
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
440
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...

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.