Does any one know how I can delete keys from tables other than designing the table in object designer and deleting it from there?
I know there is a Key virtual table where you can see all the keys of all the tables. But I can't delete keys from there, I am getting permission errors. At the same time I can run Field virtual table and delete fields using the same license so I don't think it is a license issue. If it is not possible to delete keys by running key table is there any other easy way to delete multiple keys from multiple tables?
Thanks in advance for any help
0
Comments
RIS Plus, LLC
You can disable them from sql, but suggest against it.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
The question is: Why do you want to delete "Keys"? This could cause severe trouble within NAV's business logic, as SETCURRENTKEY etc. might raise errors then.
It is reasonable to deaktivate "SQL Indexes" which are not used by the SQL Server. This requires a thorough analysis about "Index Usage", then you could just remove the SQL site indexes by setting the "Key" property "MaintainSQLIndex" to FALSE.
This could be done by C/AL Code directly in table 2000000063 "Key", for example: Regards,
Jörg
P.S.: all this could be easily accomplished with this "NAV/SQL Perfromance Toolbox": http://www.stryk.info/english/toolbox.html
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool
I am just thinking about a distant possibility of deleting hundreds of keys from hundreds of tables. It's all part of a two step navision upgrade we are working on and trying to save some time on the first import of the objects where non-primary keys may not be required.
All I wanted to confirm is through the virtual table 'Key' you cannot delete keys and there is no other way to delete keys in bulk in Navision. My best bet would be to assign all those keys to a key group and then disable the key group so that it won't build those keys during the import.
But I suggest to use a new table to store the status of the key before change and also the values of the object table so that you can restore them later.
1. Export all Tables to FOB
2. Run CU/disable all Indexes and SIFT/VSIFT
3. Convert/Migrate Database
4. Restore FOB (large tables separately, importing the FOB in several batches)
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool
I did something similar to avoid a bug about delzeroSIFTs (4SP1 version)...
the real thing i want to add is: don't disable the key, disable SQLIndex maintenance instead (as stryk suggested)...you know, setcurrentkeys problems
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
The way that I used it was with the clustered index bug (I think that was in 4.0 SP1), I wrote a processing only report that set the first key of every table to clustered.
RIS Plus, LLC
We are doing a 2 step upgrade from 3.6 to 4.0 and then from 4.0 to 2009 classic. For the first step we are importing only the tables and we will import the complete objects only during the second step. The question is at what point I need to disable the keys so that I will save the most time in the upgrade? Unfortunately there is no Key table in 3.6 so I can't do a mass update. Is there a way to disable keys in 3.6 in bulk before I start the upgrade then I could save some time in the restore also?
As long as the 'key' is enabled, regardless of whether the 'index' on SQL Server is maintained, all NAV functionality will work. There will not be any runtime errors, but query performance can be affected. SQL Server doesn't need an 'index' for sorting (most of the time), but without 'indexes', data retrieval might become really slow when queries based on non-existent indexes are executed. So, when you disable a SQL 'index' for a NAV 'key', that could mean that queries that use that particular sort order might run more slowly. The 'art' of index tuning is finding the right balance between what index to keep and what index not to keep.
For you the trick becomes to somehow list the 'indexes' that you want to maintain for the upgrade routines only, and create a routine that disables/enables them at various stages of the upgrade process. As for the key virtual table not being available in 3.7, I think you could do a technical upgrade to even 2009 and run the upgrade routines in 2009 exe's, even though the object and data is in 4.0 state.
RIS Plus, LLC
We are doing the full upgrade in 2009 executable but the restore of a 300 gb sql 2000 backup in sql 2008 took almost 24 hrs in our initial testing and then another 6 hrs to do the technical upgrade to NAV 2009 and I am trying to cut short that time if I could eliminate the unnecessary keys even before the technical upgrade.
The part about doing a tech upgrade, I meant to do a tech upgrade before running the data/object upgrade, so that you can use the Key virtual table to turn off MaintainSQLIndex.
RIS Plus, LLC
I'm just brainstorming here, this is not from experience, so I have no way of knowing how much time (if any) you would save this way. You're going to have to turn MaintainSQLIndex back on for all of the tables at some point though, so I don't know if you'll save a lot of overall time this way.
RIS Plus, LLC
I think this is simpler than a technical upgrade. And your database will probably drop to something like 130 gig making everything much faster.
1. Export tables from 3.6 database
2. Import that into a 4.0 objects only database
3. Disable the keys
4. Export the tables
5. Import that into the 3.6 database again
6. Take the sql backup
The whole objective is to save time on every step from the beginning. I guess it takes some time in step 5
No,
just copy your 3.70 database and then manually go in and untick the boxes in Object designer. In reality how many tables do you need to do? Its probably only 20 or so. In my opinion you already spent more time discussing option than it would take just to do it, and you still have to write code the other way. In any case importing objects form 400 to 370 ay not work. Or it may give errors. So is not safe.
By the way, assuming the companies are similar in size, they would be 10 gig each, i.e. tiny databases. My experience is that deactivating keys is beneficial only when you have more than 1,000,000 records in a table. So this may not actually make the upgrade faster. But since the overall size of the database will be less than half, it will help to increase the overall speed of working.
If you had one table say GL Entry with 50,000,000 records and 10 keys and 5 with sift fields then it makes a huge advantage.
A hundred tables with over 1,000,000 Records and a lot of keys? Are you sure?
I really think you are over complicating this, but probably its best to continue the way you feel comfortable with.
Really though how many tables have more than a million records?
PS go to File Database Tables and filter on No Of records >1,000,000 then check how many unique tables there are.