SQL Query optimizer

lyot
Member Posts: 202
Hi,
I had a question about the query optimizer used when NAV works with SQL server.
As I understand it isn't required that one uses the SETCURRENTKEY command in NAV anymore, since the query optimizer will deceide which is the most effeient key. One could think that this picking the most efficient key by the query optimizer takes some time (how short it may be).
So if I deceide to use the SETCURRENTKEY command in NAV, will the query optimizer still search for the most efficient key? Or will that part of query optimization be skipped? :-k
Thanx
I had a question about the query optimizer used when NAV works with SQL server.
As I understand it isn't required that one uses the SETCURRENTKEY command in NAV anymore, since the query optimizer will deceide which is the most effeient key. One could think that this picking the most efficient key by the query optimizer takes some time (how short it may be).
So if I deceide to use the SETCURRENTKEY command in NAV, will the query optimizer still search for the most efficient key? Or will that part of query optimization be skipped? :-k
Thanx
0
Answers
-
As I understand, if you use the SETCURRENTKEY then you force Sql Server to use that key, because in the query sent to Sql an index hint will be added.
Sometimes this produces better results, sometimes not. It depends on how uptodate your statistics are, if your indexes are fragmented, if you have wrong or too few or too many indexes,...
But, the time Sql Server needs to decide which index it should use is negligible. If it is not then your Sql Server requires maintenance or you should check your table design.Debugging is twice as hard as writing code. Therefore if you write the code as cleverly as possible you are by definition not smart enough to debug it.0 -
The NAV command "setcurrentkey" is on sql only for "order by" clause.
If the setcurrentkey command is not set, the sql server use the PK for "order by". The query optimizer use his statistic informations for finding the result set with (in his meaning) the "best" index.
But if you have enabled in the table "$ndo$dbconfig" for example the config
"IndexHint=Yes;Company="YourCompanyName";Table="Customer";Key=Search Name;Search Method=;Index=1" the sql server use the index 1 ("Search Name" if u use a setcurrentkey command in NAV (dependent on "Search Method"). <- But for this, u must knwo what u do
(http://www.navisionguider.dk/downloads/ ... TGuide.pdf)
RegardsDo you make it right, it works too!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