Re: Question on Locks

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 09/29/04


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)


Relevant Pages

  • Re: This works, but I dont know why :)
    ... there are overlays still on disk the exe needs ... My Clipper exes, all overlaid, are always open ... Have an active lock? ... operation the first step in execution. ...
    (comp.lang.clipper)
  • Re: Question on Threads
    ... Threads seize their current execution in two ways ... They would be put in a Object Lock Monitor Queue. ... There are also explicit locks that may or may not be implemented using synchronization and wait/notifyin the java.util.concurrent package. ... This book if full of a complete and intuitive explanation of all of the current Java Concurrency features, ...
    (comp.lang.java.programmer)
  • Re: import in threads: crashes & strange exceptions on dual core machines
    ... Do you really mean the import statement can return without having executed the cookielib module code fully? ... Yet this costs the smoothness of app startup and corrupts my believe in Python capabs of "lazy execution on demand". ... I'd like to get a more fundamental understanding of the real problems than just a general "stay away and lock and lock everything without real understanding". ... The Import Lock should be a very hard lock: As soon as any thread imports something, all other threads are guaranteed to be out of any imports. ...
    (comp.lang.python)
  • Re: multiple threads grabbing items from a vector
    ... > However if Thread 1 finished before the others it would grab the next ... I don't think a lock is the problem. ... you really need the threads to synchronize their ... execution, ...
    (comp.lang.java.help)