home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / database / sybase / 274 < prev    next >
Encoding:
Text File  |  1992-11-09  |  2.4 KB  |  67 lines

  1. Newsgroups: comp.databases.sybase
  2. Path: sparky!uunet!csfb1!lhall
  3. From: lhall@csfb1.fir.fbc.com (Lawrence Hall)
  4. Subject: RE: locking flame 
  5. Message-ID: <BxGJCs.4Lx@csfb1.fir.fbc.com>
  6. Sender: news@csfb1.fir.fbc.com (Usenet News Account)
  7. Reply-To: uunet!csfb1!lhall
  8. Organization: First Boston Corporation
  9. Date: Mon, 9 Nov 1992 16:34:03 GMT
  10. Lines: 55
  11.  
  12. In article <1992Oct29.015905.29380@panix.com>, dbenua@panix.com (David Benua) writes:
  13. |> 
  14. |> I'm having an interesting problem(?) with locking on Sybase 
  15. |> What I'd like to do is (somewhat simplified for reasons of space):
  16. |> Begin Tran
  17. |>    Select 1 record (and acquire locks) 
  18. |>    Display Dialog
  19. |>    Allow user to change record contents
  20. |>    Update record
  21. |> Commit Tran
  22. |> 
  23. |> I'd rather find something like the Oracle select for update clause. 
  24. |> Anybody have any brillant ideas? (Please, no kludges with timestamps
  25. |> and/or shadow variables, I know about those already) Anybody know how
  26. |> we knock some sense into Sybase? 
  27.  
  28.  
  29. I could not believe the problem David was having with holdlock taking an 
  30. exclusive table lock, so we did some experiments to verify this scenario - the
  31. following are some of the results :
  32.  
  33. create table x ( a char(10), b char(10), c char(10))
  34.  
  35. Populate with 5000 rows - the unique key being a + b, but no index yet.
  36.  
  37.    select * from x holdlock where a = '1' and b = '2'
  38.    This takes an exclusive table lock even though we only need one page out
  39.     of 75.  
  40.  
  41. create unique clustered index z on x(a,b)
  42.  
  43.     select * from x holdlock where a = '1' and b = '2'
  44.     With the unique index, this locks 2 page
  45.  
  46.     select * from x holdlock where a = '1'
  47.     If "a='1'" covers 25 pages, then we lock 26 pages
  48.  
  49.     If the table were ten times as large then we would end up with a table
  50.       lock again since "a='a'" would require more than 200 page locks.
  51.  
  52.     Since I have said that "a='1'" is roughly 1/3 of the table, Sybase may
  53.         decide to use a table scan rather than the index.  In this case, we would 
  54.         get a table lock as in the case with no index.
  55.  
  56.  
  57. I hope this is of some use to others on the net. 
  58.  
  59.  
  60. ----------------------------------------------------------------------------
  61. Lawrence E. Hall
  62. First Boston Corp.
  63. 5 World Trade Center 9th Floor                    uunet!csfb1!phantom!lhall
  64. NYC, NY  10048                                    lhall@csfb1.fir.fbc.com
  65. ----------------------------------------------------------------------------
  66. The Secretary will disavow all knowledge. 
  67.