home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / database / informix / 2370 < prev    next >
Encoding:
Internet Message Format  |  1992-11-10  |  5.4 KB

  1. Path: sparky!uunet!mcsun!Germany.EU.net!ira.uka.de!gmd.de!jvnc.net!darwin.sura.net!zaphod.mps.ohio-state.edu!sdd.hp.com!decwrl!gossip.pyramid.com!pyramid!infmx!davek
  2. From: davek@informix.com (David Kosenko)
  3. Newsgroups: comp.databases.informix
  4. Subject: Re: *** HELP - Index Locks are creating DEADLOCKS ***
  5. Message-ID: <1992Nov10.160339.29203@informix.com>
  6. Date: 10 Nov 92 16:03:39 GMT
  7. References: <4309@copper.Denver.Colorado.EDU> <1992Nov9.111120.25041@bernina.ethz.ch>
  8. Sender: news@informix.com (Usenet News)
  9. Organization: Informix Software, Inc.
  10. Lines: 108
  11.  
  12. By the way, you have not, in this article, descibed any deadlock
  13. situations.
  14.  
  15. Thomas Schiele writes:
  16. >Informix: Locks and Indexes 
  17. >I've noticed the following points using Informix Version 4:
  18. >1. Even if you use the option 'LOCK MODE ROW' in the SQL statement 'CREATE
  19. >   TABLE', the database will use table locks! There is no row level
  20. >   locking. 
  21. >   Row level locking works only if you use an index on that table. 
  22.  
  23. These two statements are, of course, completely false.  There most certainly
  24. is row level locking and there is not a requirement to have an index to use
  25. row level locking.
  26.  
  27. >2. If you delete a row, the next row in the index (!) will be locked too.
  28.  
  29. This is correct.  As explained in the manual (and repeated below), this is
  30. to prevent the insertion of a duplicate key value before the transaction
  31. ends.  Informix recognizes the drawbacks to this implementation and are
  32. planning an alternate method for out 6.0 release.
  33.  
  34. >3. A row can be inserted only if the next tuple in the index (!) is not 
  35. >   locked.
  36.  
  37. Yes.  The goal here was, again, to prevent inserting duplicate keys prior to
  38. the completion of another transaction.  That probably requires a bit of 
  39. explanation.  If a key value is locked, another user cannot check its value
  40. and thus cannot determine if it has the same value as the key it is inserting.
  41. Inserting a duplicate key cannot be permitted for unique indexes; for duplicate
  42. indexes, it requires modifying the (locked) key entry, to add the new rowid to
  43. the list of rowids for that key.  In either case, the insert cannot be allowed
  44. to succeed.  By locking the adjacent key, we prevent this insert.  
  45. Unfortunately, that also prevents inserting the "next value up" from the
  46. locked key.
  47.  
  48. >   Row level locking works only if you use an index on that table. 
  49.  
  50. Again, this is not true. 
  51.  
  52. >I've found in the complete documentation for Informix one (!) remark only:
  53. >   "A process running under Informix-OnLine acquires an exclusive 
  54. >   lock on a row before it updates a table, deletes a row, or inserts
  55. >   a row. A exclusive lock prevents another process from modifying the
  56. >   contents of the row before the lock is released. The delete process
  57. >   also locks the next, or adjacent key, value in the index. This
  58. >   feature ensures that another process does not insert a row with
  59. >   the same value as the deleted key until the lock is released. The
  60. >   insert process acquires an exclusive lock on the row and checks to 
  61. >   make sure that the next, or adjacent key, values are not locked. If
  62. >   the values are locked, then the insert fails." (Informix-OnLine
  63. >   Administrator's Guide)
  64. >My remarks:   
  65. >1. Row level locking works with indexes only. You have to use an index 
  66. >   even if you don't need it.
  67.  
  68. Repeating it does not make it true.  THIS IS NOT TRUE.
  69.  
  70. What you may be seeing is this: using higher isolation levels (REPEATABLE
  71. READ) will cause table level locks to be placed when queries do not use
  72. indexes.  This is actually an optimization, believe it or not: since RR
  73. locks all rows examined, and a non-indexed read must examine every row
  74. (sequential scan), the alternative is to lock each individual row.  In such
  75. a case, a table lock is much less costly.
  76.  
  77. Perhaps you could describe your application, in order to allow others to
  78. understand what you are trying to accomplish.  You would then be more likely
  79. to receive useful suggestions.
  80.  
  81. >   It seems that locking is implemented via ISAM index locking. 
  82.  
  83. Not true at all.
  84.  
  85. >2. There are conflicts between insert and/or delete operations because   
  86. >   row level locks affect neighbour tuples in the index (side effect
  87. >   called 'feature'!). Deleting the last row in the index even locks 
  88. >   the index to the end, no more rows can be inserted.
  89.  
  90. This is basically tru, and is an unpalatable side-effect of this locking
  91. strategy.  Again, Informix recognizes this and is re-engineering it for our
  92. 6.0 release.
  93.  
  94. >3. There are no hints in the documentation which strategy to use for   
  95. >   defining an index in order to have correct row level locking.
  96.  
  97. That is because it is not a requirement to have indexes in order to
  98. have row level locking.
  99.  
  100. >   For example it is not defined, whether one must use all fields of
  101. >   all WHERE clauses (!) of a whole application (!!) to have correct row
  102. >   level locking. It is even not defined how locking works if there is 
  103. >   more than one index on a table.
  104. >>>Can anyone help:
  105. >...I need some help too (or is this really a 'feature' of informix?)...
  106.  
  107. Again, if you could provide some idea of what your application is doing
  108. (esp. what isolation levels are used, logging on or off, etc), it would be
  109. easier to provide advice.
  110.  
  111. Dave
  112. -- 
  113. Disclaimer: These opinions are not those of Informix Software, Inc.
  114. **************************************************************************
  115. "I look back with some satisfaction on what an idiot I was when I was 25,
  116.  but when I do that, I'm assuming I'm no longer an idiot." - Andy Rooney
  117.