What's wrong with this query? What makes it inefficient?

Miklos_Hollender
Member Posts: 1,598
(@P1 varchar(20))SELECT TOP 1 * FROM "customerdatabase"."dbo"."Company$CustomEntryTable" WHERE (("Source Document No_"=@P1)) ORDER BY "Source Document No_","Line Identifier","Quote Quantity","Entry No_"
It looks perfect to me - the ORDER BY cause seems to suggest we are using the correct SETCURRENTKEY.
Still I got max_logical_reads like 71564.
Other stuff:
HW: inadequate I think (VMware Virtual SCSI - I don't think that's a good option) - I'll look into it but it's not related to max_logical_reads.
Client: 5.0SP1 Build 26084, SQL: 2005, 9.0.3042 - probably neither are the latest, but I'd like to update only if it is very clear it would help because the users are a bit angry, further downtime for server update / client update I only want to risk if it's really justified...
Server is very new so index stats and index fragmentation should not count yet (although a backup that ran for years without this was restored to there from SQL2000 so maybe yes?)
Index Hinting is turned off. RECOMPILE is not yet used, as I have no idea what that is and why and how it is to be used - any documentation?
0
Comments
-
Welcome to 5 SP 1.
Did you use the SQL index property?
I've created some unbelievable weird indexes on SP1 to get it running, indexes agains all basic knowledge in the NAV world.
Good for our business but inconvenient for people who just implement the old knowledge...
Don't worry about VMWare, should work like a charm and if any issues, look in VMWare settings, not NAV/SQL0 -
Thanks. Didn't use it - it's already on max. selectivity, compared to the query. So you say there are some special tricks for 50SP1/SQL2005?0
-
Hi!
Well, actually you NAV and SQL versions are somewhat old; especially your NAV is affected by some severe bugs ...
For recent NAV versions you might check out this one: http://dynamicsuser.net/blogs/waldo/archive/2009/03/04/platform-updates-overview-3-70-b-nav2009-rtm-updated.aspx
With NAV your SQL Build should be at least SP2 Update 4 Build 3200, with this Update MS has introduced several fixes specifically for NAV, and this version is required to use RECOMPILE hints properly. But actually already SP3 Update 2 has been released; see http://dynamicsuser.net/blogs/waldo/archive/2009/03/04/platform-updates-overview-3-70-b-nav2009-rtm-updated.aspx
Regarding your specific problem:
First of all, is it sure the "SQL Index" of that key "Source Document No_","Line Identifier","Quote Quantity","Entry No_" is maintained?
You could also try to simply copy the "Key" content to the "SQL Index" property (if this is NOT the PK).
Any changes then?
Kind regards,
JörgJörg A. Stryk (MVP - Dynamics NAV)
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool0 -
Thanks, I'll try these.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions