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

  1. Path: sparky!uunet!ogicse!uwm.edu!linac!sunova!higgs.ssc.gov!jbaron
  2. From: jbaron@higgs.ssc.gov (Jeff Baron)
  3. Newsgroups: comp.databases.sybase
  4. Subject: RE: locking flame
  5. Message-ID: <1992Nov9.185829.19395@sunova.ssc.gov>
  6. Date: 9 Nov 92 18:58:29 GMT
  7. Article-I.D.: sunova.1992Nov9.185829.19395
  8. References: <BxGJCs.4Lx@csfb1.fir.fbc.com>
  9. Sender: usenet@sunova.ssc.gov (News Admin)
  10. Reply-To: jbaron@higgs.ssc.gov (Jeff Baron)
  11. Organization: Superconducting Super Collider Lab
  12. Lines: 31
  13. Nntp-Posting-Host: higgs.ssc.gov
  14.  
  15. Lawrence Hall writes:
  16.  
  17. - create table x ( a char(10), b char(10), c char(10))
  18. - Populate with 5000 rows - the unique key being a + b, but no index yet.
  19. -    select * from x holdlock where a = '1' and b = '2'
  20. -    This takes an exclusive table lock even though we only need one page out
  21. -     of 75.  
  22.  
  23. This locks all of the table in order to prevent another process 
  24. from inserting data into the table that might somehow change the 
  25. results of this query while the transaction that this query is embedded
  26. in is still active.
  27.  
  28. - create unique clustered index z on x(a,b)
  29. -     select * from x holdlock where a = '1' and b = '2'
  30. -     With the unique index, this locks 2 page
  31.  
  32. You should be able to see that now, Sybase can prevent someone from
  33. inserting an 'a=1, b=2' record by locking only the pages in the table
  34. where that record would be located, since it is *known* where
  35. that record would be.  (I wonder, in fact, if the 2nd, or even both,  
  36. pages are higher-in-the-index-tree index pages of some sort, presumably the
  37. ones that sit "above" the record(s) in question.  The net result would
  38. be identical.)
  39.  
  40. --
  41. Jeff Baron
  42. jbaron@gauss.ssc.gov
  43.