Re: Question on Locks
From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 09/29/04
- Next message: Allen Davidson: "Re: Resetting DTS password"
- Previous message: Vishal Khajuria: "Re: handling apostrophe"
- In reply to: rgn: "Re: Question on Locks"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 29 Sep 2004 14:03:17 +0200
On Wed, 29 Sep 2004 02:23:11 -0700, rgn wrote:
>Even when I use a WHERE clause in the SELECT (from terminal two), the session
>just hangs. This is something that I'm not able understand. Why should the
>user
>from Terminal Two wait to read records that were already committed.
Hi rgn,
I too should have been clearer.
Yes, in this case every query executed from another window will wait for
the locks to be released. Since there is no index that can be used to
satisfy the request, the execution plan will be a plain table scan. For a
table scan, every row must be read. So you'll have to wait until the lock
is released. SQL Server can't see what the "previous" contents of the row
were. You and I know that the locked row is new, but updating the value
for a of an existing row results in the same data in the database. And if
the update would be rolled back, you'd expect to see the original row in
your results (if the original row does match the WHERE clause).
In a production database, columns that are searched on a regular basis
will probably be indexed. No need for a table scan. And if a rare search
is made that does require a table scan, then the execution time will be
hampered more by the overall slowness of a table scan against a production
size table than by some milliseconds of waiting for a lock to be released.
Best, Hugo
-- (Remove _NO_ and _SPAM_ to get my e-mail address)
- Next message: Allen Davidson: "Re: Resetting DTS password"
- Previous message: Vishal Khajuria: "Re: handling apostrophe"
- In reply to: rgn: "Re: Question on Locks"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|