Add or Modify key

andrejsm
Member Posts: 122
Hi, I need new key in table G/L Entry : "Document No.,Posting Date, Source Type, Source No.".
There is one secondary key "Document No.,Posting Date" in the G/L Entry. Is it better to extend existing key with addition fields, or add new key?
There is one secondary key "Document No.,Posting Date" in the G/L Entry. Is it better to extend existing key with addition fields, or add new key?
Andrejs Muraskins
0
Comments
-
First : do you need to sort on those fields or are they only because you set filter on them?
If they are only to put some extra filters, it is not even necessary to add them to the key (or make a new key).
If you put a filter on "Document No.", you already limit a lot to the records. Adding fields to the key (or a new key) slows down write-performance and adds only a little to read-performance.
Without extra fields, write-performance doesn't slow down and read-performance almost don't suffer anyway.
In case you need to sort on the new fields, you can add these fields to the existing key. This is not the case for all keys. But this key is only used in the Navigation-form, so no problem.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
There was mistake in my description of problem, I forgot about "Document No.", the value is unknown and I can't use it for filtering purposes.
Now, i see that problem could be devided in two parts:
1) I need filter, but on key "Posting Date, Source Type, Source No.";
2) Then I need to open form with key "Document No., Posting Date".
I decide to make new key "Posting Date, Source Type, Source No."Andrejs Muraskins0 -
andrejsm wrote:There was mistake in my description of problem, I forgot about "Document No.", the value is unknown and I can't use it for filtering purposes.
Now, i see that problem could be devided in two parts:
1) I need filter, but on key "Posting Date, Source Type, Source No.";
2) Then I need to open form with key "Document No., Posting Date".
I decide to make new key "Posting Date, Source Type, Source No."
Why? For performance reasons :
1) Try to keep dates as last field in a key
2) Try to get as first field, the field that retains least fields (except ofcourse date-fields).
I explain this last one:
-There are only 5 different values for "Source Type". So a filter on it will retain still 20% (on average) of all the records.
-"Source No." : there are a lot more values for this (lets say you have 10000 different values between customers+vendors+banks+fixed assets. So on average you only have 0.01% (on average) of all the records!
-"Posting date":no good because of rule 1.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Extending existing keys can always lead to unforeseen problems. The primary key is always added to the secondary keys to make them unique. If the key is set in a code, and a program was indended to step through the table in the indended order, adding fields to the key will change that order. This can lead to very strange results if calculations are performed. These problems are very difficult to detect if the change was not documented.Kai Kowalewski0
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