LOCKING at INSERT with VSIFT

stefan.jossen
Member Posts: 14
Hello out there.
I like the RECORDLEVELLOCKING of the NAV-SQL.
I also like the new SQL-views VSIFTS inside the SQL with NAV-SQL 5.1 and up.
But:
Can you explain to me WHY the INSERT of a single RECORD LOCKS almost the whole table if there is a SIFT on a KEY?
I thought that next to the actual RECORD and the update of the different INDEXES there would be no additional data written into the database because of the VSIFT beeing a VIEW.
Stefan
I like the RECORDLEVELLOCKING of the NAV-SQL.
I also like the new SQL-views VSIFTS inside the SQL with NAV-SQL 5.1 and up.
But:
Can you explain to me WHY the INSERT of a single RECORD LOCKS almost the whole table if there is a SIFT on a KEY?
I thought that next to the actual RECORD and the update of the different INDEXES there would be no additional data written into the database because of the VSIFT beeing a VIEW.
Stefan
0
Answers
-
I noticed exactly the same.
We have a benchmark database with this issue which we are ready to downgrade to 4.0 SP3 with updates to see what happens...0 -
The SIFT is a managed view which means it has its own indexes.
Is this a small or a large table?
I suspect it has to lock the index rows while it is inserting.
It would be interesting to get a more in depth terchnical overview of what is happening.David Machanick
http://mibuso.com/blogs/davidmachanick/0 -
@Stefan: Could you explain which table - for example - is affected by this? What do you mean with "almost the whole table" - what is actually locked?Jörg A. Stryk (MVP - Dynamics NAV)
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool0 -
Hi all
Does anybody have more information about this issue? Is there a workaround?
wakestar0 -
From manual 5 of manual i posted here:
http://www.mibuso.com/forum/viewtopic.php?f=34&t=36804MaintainSIFTIndex
[...]Also be aware that even the new implementation that uses indexed views will
cause blocking in the database. For example if two users update the total for an
account on the same date.0 -
Belias wrote:From manual 5 of manual i posted here:
http://www.mibuso.com/forum/viewtopic.php?f=34&t=36804MaintainSIFTIndex
[...]Also be aware that even the new implementation that uses indexed views will
cause blocking in the database. For example if two users update the total for an
account on the same date.
Thanks for the info.
I was not aware of that:
The VSIFTs are saved within SQL as indexed tables.
This means that SIFT's on keys will lock the whole range of the filter...0 -
stefan.jossen wrote:Belias wrote:From manual 5 of manual i posted here:
http://www.mibuso.com/forum/viewtopic.php?f=34&t=36804MaintainSIFTIndex
[...]Also be aware that even the new implementation that uses indexed views will
cause blocking in the database. For example if two users update the total for an
account on the same date.
Thanks for the info.
I was not aware of that:
The VSIFTs are saved within SQL as indexed tables.
This means that SIFT's on keys will lock the whole range of the filter...
This is not correct. VSIFT are indexed "Views",not "Tables" - that's a remarkable difference. Those VSIFT use have a Clustered Index which Leaf Nodes actually contain the aggregated sum values.
Thus, when a record is inserted into a table - e.g. Item Ledger Entry - the CI of the related VSIFT Views are updated. During this update certain rages of these indexes are locked, thus blocking conflicts could occur.
Any "filter ranges" have no impact on this VSIFT update process. When other processes are querying sums from the VSIFT during the the VSIFT update then blocks might occur.
The Ledger table itself is not fully locked - only the inserted record ROW X and the container-page PAG IX.Jörg A. Stryk (MVP - Dynamics NAV)
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool0 -
stryk wrote:This is not correct. VSIFT are indexed "Views",not "Tables" - that's a remarkable difference. Those VSIFT use have a Clustered Index which Leaf Nodes actually contain the aggregated sum values.
Thus, when a record is inserted into a table - e.g. Item Ledger Entry - the CI of the related VSIFT Views are updated. During this update certain rages of these indexes are locked, thus blocking conflicts could occur.
Any "filter ranges" have no impact on this VSIFT update process. When other processes are querying sums from the VSIFT during the the VSIFT update then blocks might occur.
The Ledger table itself is not fully locked - only the inserted record ROW X and the container-page PAG IX.
Thank you for the explanation!
Within Navision I have never tried removing the "clustered index"-property from the primary key.
If we have to keep the SIFTS - would it be a possibility to turn off this property?0 -
Hmm, I think the explanation was correct but the penny has not really dropped yet.
No offense, the VSift is immensly complex to understand.
The clustered index property in the navision table keys have nothing to do with this and cannot be turned of. ( In the last versions).
Please do not change anything on SQL Level. This is extremely dangerous and can lead to corrupt databases.0 -
Mark Brummel wrote:Hmm, I think the explanation was correct but the penny has not really dropped yet.
No offense, the VSift is immensly complex to understand.
The clustered index property in the navision table keys have nothing to do with this and cannot be turned of. ( In the last versions).
Please do not change anything on SQL Level. This is extremely dangerous and can lead to corrupt databases.
No offense taken. I'm eager to learn more.
I keep on hammering on the SIFT-subject because I had to redesign some (standard) reports that fell asleep running under SQL.
The sifts are to me a main reason for bad performance - next to bad code, keys and filters within loops...
Till now I tried to resolve the issues within Navision but I'm really not sure about sifts and SQL.0 -
Don't worry - even as SIFT/VSIFT is somewhat complex we're not talking about "Recket Scienece" here 8)
Since you are running VSIFT there should be less harm than with the old stndard (non-optimized) SIFT. If a certain VSIFT record indeed is a problem you could find out with proper block/deadlock detection (http://dynamicsuser.net/blogs/stryk/archive/2008/11/03/blocks-amp-deadlocks-in-nav-with-sql-server.aspx) and query profiling (http://dynamicsuser.net/blogs/stryk/archive/2009/11/26/technical-airlift-2009-munich-nav-sql-performance-optimization-indexes.aspx).
Once you have identified a problematic VSIFT you could deal with it: first start an "effectivity analysisis", means check how many records are stored in the base table, how many records contains the VSIFT and how many zero-sum-records contains the VSIFT. If the VSIFT is ineffectivy anyway you could set the "MAintainSIFTIndex" proprety of the related "Key" to FALSE. If the VSIFT is necessary the you could improve its performance by adding optimized indexes (SQL site only) ...
But then again: first thing must be to IDENTIFY the problematic queries and VSIFT ... knowing, not guessing ...
P.S.: You know about this one? http://dynamicsuser.net/blogs/stryk/archive/2009/12/09/the-nav-sql-performance-field-guide.aspxJörg A. Stryk (MVP - Dynamics NAV)
NAV/SQL Performance Optimization & Troubleshooting
STRYK System Improvement
The Blog - The Book - The Tool0 -
Thank you very much for all this!
=D>
I'll try to pull back from daily business and get to learn the tools properly.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