473,586 Members | 2,681 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 2872
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*****@btinte rnet.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*****@btinte rnet.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********@sne t.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.publi c.sqlserver.pro gramming
for this sort of question.

Roy Harvey
Beacon Falls, CT
Oct 13 '08 #5
John Rivers (fi*****@btinte rnet.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****@sommarsk og.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
1958
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 order by customer_id; QUERY PLAN: Index Scan using cust_pkkey on customer (cost=0.00..5175.17 rows=102834 width=724)
21
1882
by: rkusenet | last post by:
Trolling before someone else does -) http://www.eweek.com/article2/0,1759,1776048,00.asp
9
2796
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 the following commands: set current query optimization 9;
9
3758
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++ you can put the 'inline' keyword for properties and methods that could be inserted into the generated code so you avoid a call and thus the...
2
1291
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
2223
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 procedures. SQL Server will be used by a vendor packaged application. The problem is that we are awaiting word on whether it will be SQL Server 2000 or...
7
1444
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. Becuase the Express IDE supposedly doesn't optimize the compiled output as much as the professional IDE does. If that's so, then it sounds like their are...
2
3900
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 still exist in MS SQL 2005? The BOL seems to be silent on the issue. Boa
0
7839
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...
0
8338
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...
0
8216
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...
1
5710
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...
0
5390
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...
0
3837
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...
1
2345
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
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
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...

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.