home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.databases.sybase
- Path: sparky!uunet!csfb1!lhall
- From: lhall@csfb1.fir.fbc.com (Lawrence Hall)
- Subject: RE: locking flame
- Message-ID: <BxGJCs.4Lx@csfb1.fir.fbc.com>
- Sender: news@csfb1.fir.fbc.com (Usenet News Account)
- Reply-To: uunet!csfb1!lhall
- Organization: First Boston Corporation
- Date: Mon, 9 Nov 1992 16:34:03 GMT
- Lines: 55
-
- In article <1992Oct29.015905.29380@panix.com>, dbenua@panix.com (David Benua) writes:
- |>
- |> I'm having an interesting problem(?) with locking on Sybase
- |> What I'd like to do is (somewhat simplified for reasons of space):
- |> Begin Tran
- |> Select 1 record (and acquire locks)
- |> Display Dialog
- |> Allow user to change record contents
- |> Update record
- |> Commit Tran
- |>
- |> I'd rather find something like the Oracle select for update clause.
- |> Anybody have any brillant ideas? (Please, no kludges with timestamps
- |> and/or shadow variables, I know about those already) Anybody know how
- |> we knock some sense into Sybase?
-
-
- I could not believe the problem David was having with holdlock taking an
- exclusive table lock, so we did some experiments to verify this scenario - the
- following are some of the results :
-
- create table x ( a char(10), b char(10), c char(10))
-
- Populate with 5000 rows - the unique key being a + b, but no index yet.
-
- select * from x holdlock where a = '1' and b = '2'
- This takes an exclusive table lock even though we only need one page out
- of 75.
-
- create unique clustered index z on x(a,b)
-
- select * from x holdlock where a = '1' and b = '2'
- With the unique index, this locks 2 page
-
- select * from x holdlock where a = '1'
- If "a='1'" covers 25 pages, then we lock 26 pages
-
- If the table were ten times as large then we would end up with a table
- lock again since "a='a'" would require more than 200 page locks.
-
- Since I have said that "a='1'" is roughly 1/3 of the table, Sybase may
- decide to use a table scan rather than the index. In this case, we would
- get a table lock as in the case with no index.
-
-
- I hope this is of some use to others on the net.
-
-
- ----------------------------------------------------------------------------
- Lawrence E. Hall
- First Boston Corp.
- 5 World Trade Center 9th Floor uunet!csfb1!phantom!lhall
- NYC, NY 10048 lhall@csfb1.fir.fbc.com
- ----------------------------------------------------------------------------
- The Secretary will disavow all knowledge.
-