Creating Keys for Base Application is Essential
I have seen the issue #456 (Standard Table Field Keys in Table Extension). Since this issue is closed, but not resolved I would like to raise awareness that for serious data volumes creating keys for base application fields as well as own fields in Table Extensions is really really necessary.
In the last 10 years, I had so many performance issues, which was ether, solved be Microsoft or creating the right key. Please consider enabling the creation of additional keys for us.
Thanks for the feedback. We know this is important and are considering alternatives that solve the performance problem without actually requiring changes to the base (shared) table's indexing situation.
The limit of about 40 keys should also be considered.
What about the fact that the base code does not use the proper key?
Don‘t get my intension wrong. For a NAV Key an SQL Index will be created. E.g. If you have large amounts of entries in a table and no index for a fields, SQL Server has to lookup every entry, which takes longer than using the index.
Just a thought:
How about enable the possibility of mixed keys?
Technical speaking I would split the key for the different tables. For every related table (base table, other extension and my extension) there should be a key, which only contains the fields of its table.
For creating that SQL Key, I would only create it, if there were no matching key for my partial key.
Mixed keys has technical merit, but is problematic from the standpoint of multiple tenants living in the same tenant database. We want to avoid alterations to the base/shared table completely. We are more likely to implement something that lets us define the new index completely on the extension's table (like platform-managed field mirroring for fields needed in new indexes).
To add another view to this discussion. There may be also the need to change/extend primary keys (which is currently not possible if i understand the posts above) Customers may for example need to implement Sales Prices by Responsibilty Center or time dependend (happy our). This is curently possible in C/AL by changing the Primary Key and extending the "Sales Price Calc. Mgt."- Codeunit. How can we handle this in AL? It's just an idea: What would happen if we remove the primary key as we know it today and change it internaly to an Entry No, . This would allow any secondary (virtual primary) key. There would be some adminstration effort to ensure that (virtual primary) keys are uniqe by tennant on writing tables, but reading should be easy via Entry No. . Probably Tenant and Master use the same Entry No. as "Master Primary Key"
We are more likely to implement something that lets us define the new index completely on the extension's table (like platform-managed field mirroring for fields needed in new indexes).
@cmrudolph-msft any news about this feature? Add mirrored fields to table extension and improve the query generator seems the most quick and right way. Working with extensions in real and huge environment is a big issue without this feature.
Thank you S.
@sgiordy This unfortunately has not made the cut yet. It's on the current priority list, but that list is still being refined. We hear about this often and understand it is a problem.
I have a specific example. I need to Enable a base key, which is disabled by default. (T337, Key "Lot No.")
Is this possible, as of now?
@JSebastianN No - not supported.
@cmrudolph-msft remind :D please remember about keys, flowfield and related performance issues ... without these (or similar) functions only small customers can go on 365BC cloud. Thank you.
Adding custom keys to standard tables is a must to have. There are very high performance issues when you have a huge amount of data in a standard table and you can’t add the key you need. We need a way to create a table extension and add a new key. Modifying existing ones I can agree that could be avoided.
We have the same issue. We need specific keys for standard ledger tables. The workaround to mirror the fields in the table extension is not an option for us.
How about disabling an existing standard key, by setting MaintainSQLIndex to false?
From a performance perspective this is common practice to do every now and then. Especially on big tables like Sales Shipment Line.
Is this considered for the future?
I Think MaintainSQLIndex to false is not the solution, because especialy flowfields on Ledger Entries require well adjusted realy existing keys.
What happens if both keys needed? What happens if primary key has to be changed?
And as Hilbekale already said. mirroring is not a solution, because other extension may also require the same information (f.e. Sales Pricees)
I Think MaintainSQLIndex to false is not the solution, because especialy flowfields on Ledger Entries require well adjusted realy existing keys.
Agree in general, but tuning your application from a performance perspective it might be needed (and possible in the context of flowfields etc.) to disable an index based on a BC key as the system is maintaining it while it's of no use.
Do we have any update on this ? Can we add standard fields in keys ?
Would like to hear about it as well. Is there a plan for supporting custom keys or not? As far as we can, this is one of the main concerns for moving our on-premise to extensions. Due to performance reasons we had to modify quite some keys: for e.g.
- disabling standard keys is very common. not all parts of the standard NAV application is used. Therefore there's no point to maintaining the key for them. for e.g. we don't use lots and variants. after key is disabled we often create simplified version of the same key.
- in addition to that, where are some strange MS decisions when it comes to adding keys on big tables like item ledger entries (MS 2018 CU6). in those case we also like to disable keys, and remove functionality.
- similar case happens with other add-ons. for e.g. we are using LS Retail add-on, where we also modify keys for the biggest table to tackle performance issues.
- change PK for temporary tables. it's common practice to use buffer table for grouping data before posting. you can see this pattern in MS code, and other add-ons. It's very common change to add custom field into the primary key of the table so you would include your custom field into the grouping.
- for Item table we have we have custom key that combines MS fields, LS fields, and our fields. We use this key as main sorting for the Item list. Since this page is so often used, we made this sorting option as a key.
what would be other alternatives?
- we could mingle with indexes on SQL level without NAV even knowing. On SQL level we can disable keys, or make indexed for combining multiples tables. On the other hand, this approach would lead to management, and deployment problems.
Question, If I understood it correctly, cross keys are possible for fields part of the primary key (see post by hunterfeltman). But I cannot get it to work. How do you reference fields that are part of the primary key of the main table in the table extension key ? (I get the error AL0186: Reference '"Item No."' in application object 'Sales Price Extension' does not exist) And could that key replace the original primary key? example code please!
I am also wondering about Hilbekale's comment how do you mirror the fields?