keys in Nav

Angelo
Member Posts: 180
Hi master,
When I compare nav4.0 SP1 and Nav5.0 there is change in key. for example in Sales line. the primary key is "Document Type,Document No.,Line No." (nonclustered) and secondary key is "Document No.,Line No.,Document Type" (clustered)
If I want to change my key in nav4.0 SP1 same as Nav 5.0, is it true if I just add new key below the primary key (Document No.,Line No.,Document Type) ,remove clustered in primary key, and then make clustered key in my new key?
if primary key is still using "Document Type,Document No.,Line No." .why add new key make performance improve?
please advices.......
rgds,
angelo
When I compare nav4.0 SP1 and Nav5.0 there is change in key. for example in Sales line. the primary key is "Document Type,Document No.,Line No." (nonclustered) and secondary key is "Document No.,Line No.,Document Type" (clustered)
If I want to change my key in nav4.0 SP1 same as Nav 5.0, is it true if I just add new key below the primary key (Document No.,Line No.,Document Type) ,remove clustered in primary key, and then make clustered key in my new key?
if primary key is still using "Document Type,Document No.,Line No." .why add new key make performance improve?
please advices.......
rgds,
angelo
0
Comments
-
The selectivity of first first the in the index is higher for the index
Document No.,Line No.,Document Type
Document No is more unique than Document Type.0 -
yes,Doc no is more unique.
if my codes :
SalesLine.setrange(Doctype,doctype::"zzz");
SalesLine.setrange(Line No,xxxx);
SalesLine.setrange(DocNo,'yyyy');
if I'm not use setcurrentkey,nav still using primary key(Doctype,lineno,docno). So,what the function of new key (docno,lineno,doctype)? should I use setcurrentkey(docno,lineno,doctype) before setrange?
pls advice0 -
If you are using SQL, SQL will use best index regardless the SETCURRENTKEY. SETCURRENTKEY on SQL is just about sorting order, nothing about indexes.0
-
i'm using SQL.
Kine,
you mean if I do not put setcurrentkey before setrange, sql will automatically use secondary key(docno,lineno,doctype) although the primary key is doctype,lineno,docno ?0 -
SQL will each time select best key based on statistics and actual parameters. Sorting order can influence this selection process but not so much. All this is true if IndexHinting is disabled. SETCURRENTKEY just add "Order By" clausule to the select statement. SQL has own mechanism to select best index for reading data from DB.0
-
Ok, I see.
if I dont make new secondarykey like Nav5.0. Keep using standard nav4.0 sp1, using doctype,lineno,docno key but I set sqlindex to docno,lineno,doctype. the performance will be same as in Nav5.0?0 -
Problem is, that you cannot change the key field order on Clustered index through SQLIndex property and it is why they created new key and set this as clustered... (but I am not sure)...0
-
kine wrote:Problem is, that you cannot change the key field order on Clustered index through SQLIndex property and it is why they created new key and set this as clustered... (but I am not sure)...
You can change the pk that is clustered and have a diff sql index.0 -
ara3n wrote:kine wrote:Problem is, that you cannot change the key field order on Clustered index through SQLIndex property and it is why they created new key and set this as clustered... (but I am not sure)...
You can change the pk that is clustered and have a diff sql index.
I never tried to change the SQL key on the primary key because, to be honest, I am afraid it can create trouble.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
I used to set the SQLIndex of the primary key to DocNo, LineNo, DocType, and then the additional key was added as the clustered index. The person who did that says it gives better performance that way, so ever since I've been doing it that way as well.0
-
Ok,
Now, How to compare and see the performances?
I make some scenarios in Sales Header:
1. Using Default primary key(DocType,No), clustered = Yes
2. make new key(No,DocType) and make it clustered (like Nav5.0)
3. Using Default primary key(DocType,No),clustered = Yes, sqlindex = No,DocType
then I make query : "Select * from Sales Header" then compare CPU time, Reads, Write in SQL Profiler. Why sometime No. 1 is better than another?Why No. 2 better than another and Why also sometime No. 3 is better than another? What the exactly way to compare performance beside using SQL Profiles?is there another tool?
Pls Advices.....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