Autoincrement in ledger tables

davmac1
Member Posts: 1,283
I have reviewed some of the previous posts about autoincrement. Also asked a Microsoft employee about it. His comment is the current locktable method will stay as long as there is a native database.
Jörg A. Stryk wrote that he had implemented autoincrement, but added GUID as the clustered index to avoid locking problems.
One question I have about this method, don't you end up with frequent page splits if you use this method, which you will never have with a clustered index based on entry no.? Do you start out with a low fill factor on the ledger tables to reduce the occurence?
Has anyome been running at least several months on a high transaction database using autoincrement and is stilkl happy with it?
Jörg A. Stryk wrote that he had implemented autoincrement, but added GUID as the clustered index to avoid locking problems.
One question I have about this method, don't you end up with frequent page splits if you use this method, which you will never have with a clustered index based on entry no.? Do you start out with a low fill factor on the ledger tables to reduce the occurence?
Has anyome been running at least several months on a high transaction database using autoincrement and is stilkl happy with it?
David Machanick
http://mibuso.com/blogs/davidmachanick/
http://mibuso.com/blogs/davidmachanick/
0
Comments
-
Hi!
Well, with the appropriate Fillfactor you won't get that many Page Splits, but probably more than with the "Entry No." CI. Of course, a GUID (16 bytes) index is remarkably larger than an integer (4 bytes) index, and the FF needs to be lower than 100% - hence, a GUID index is larger and forcing "physical disorder". The performance when Reading may be worse, too. The GUID thing is inteded to prevent blocking issues only.
That's what I tried to point out during my presentation (and in my BLOG): It always depends! It's all a matter of balance! There is no "silver bullet" to fix things, every solution has advantages and disadvantages ... that's what makes troublshooting such a "tricky business" ...
You really have to test this first. And have in mind: DON'T DO IT ON FISCALLY RELEVANT TABLES like G/L Entry, VAT Entry, Value Entry, Customer Ledger Entry, etc.!Jörg A. Stryk (MVP - Dynamics NAV)
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool0 -
You can use the autoincrement-property without problems. When 2 sessions are inserting records in the table with a clustered key that is autoincrement, they DON'T lock each other.
I just tried it to be sure.
I created a table with 2 fields in it : the clustered index (an integer) that is autoincrementing and a session ID in which I save the sessionID of the session.
I launched 2 clients to insert 10000 records in it in 1 transaction. Then I checked the records and I saw that the session-ID's alternate between the 2 sessions!
The GUID is another way to avoid the locking, but has some extra problems:
-it is BIG in confront with an integer (or even a biginteger).
-it can create a lot of pagesplits in the database, depending on the fillfactor on the index on it.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
kriki wrote:You can use the autoincrement-property without problems. When 2 sessions are inserting records in the table with a clustered key that is autoincrement, they DON'T lock each other.
I just tried it to be sure.
I created a table with 2 fields in it : the clustered index (an integer) that is autoincrementing and a session ID in which I save the sessionID of the session.
I launched 2 clients to insert 10000 records in it in 1 transaction. Then I checked the records and I saw that the session-ID's alternate between the 2 sessions!
The GUID is another way to avoid the locking, but has some extra problems:
-it is BIG in confront with an integer (or even a biginteger).
-it can create a lot of pagesplits in the database, depending on the fillfactor on the index on it.
Yes, but still you need to have on mind, that when posting, you need to lock the table to prevent others to change the data during your posting, else you can have inconsistent database (e.g. when used with Item Ledger Entry).0 -
Since NAV is inserting ledger rows, why would there be data inconsistency? Especially if all ledger tables were changed to use identity columns as the clustered index?David Machanick
http://mibuso.com/blogs/davidmachanick/0 -
davmac1 wrote:Since NAV is inserting ledger rows, why would there be data inconsistency? Especially if all ledger tables were changed to use identity columns as the clustered index?
Because if you read some data to e.g. calc sum, and you create new entry based on this sum, and some other process will read same set of record, calc the sum and create another record, you will have two records based on same data but together giving you wrong result... ;-) it is why LockTable is used for - to prevent changes of record set you have read....0 -
Typically the ledger table is locked for inserting new rows. Are the tables whose rows are summed locked as well or just the rows - like the sales header?David Machanick
http://mibuso.com/blogs/davidmachanick/0 -
If you use LockTable, all records you read from that table will be locked...0
-
The codeunit for posting GL Ledger Entries inserts new rows - if the table was not locked, how would that affect the correctness of new rows?
As long as the commit is done after all the ledger rows have been inserted, wouldn't that keep the entries correct and consistent?David Machanick
http://mibuso.com/blogs/davidmachanick/0 -
The posting routines are also dependent on the entries for a given posting to be consecutive.There are no bugs - only undocumented features.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