Hello
While creating a new key on a entry table with tons of record the following question occured to me:
An export neeeds to key to export the records to somewhere else, based on these 3 criterias:
1: Document Type (Option Field)
2: Document No. (Code Field)
3: Processed (Boolean Field)
DB is the native one!
In my opinion the navision way is to make the key in the order 1,2,3. But from a performance point of view I guess "Processed" should be the first field in the key, because it is the most selective field, having tons of records in the table but anyway the export will find only a few hundreds records at one time and then sets the "Processed" field to true.
Additional question: If the DB is sql server, is there a difference regarding the proper usage of such a key?
I'm looking forward to some opinions.
Thank you in advance
Thomas
0
Answers
The thing is that with a dynamic cursor, you are basically emulating Navision logic, so SQL is not building a proper execution plan based on statistics, its just "doing as its told" so it all a bit hyperthetical.
So if Primary Key is Document Type, Document No, then the secondary key of Processed would be sorted by Processed, Document Type, Document No.
To sum it up: Don't you just need a key with the Processed field?
My Blog - nav.education
RIS Plus, LLC
On an entry table the primary key will be "Entry No." an integer. 8)
it really depends on the filter applied to "Document No." if its a setrange, then correct the selectivity does not matter, but if its a ranged filter or * or | then the order makes a huge difference.
RIS Plus, LLC
I'll set the thread to solved.
Regards
Thomas