3. Statements : OpenROAD SQL Statements : Set Statement : Lockmode
 
Share this page                  
Lockmode
The set lockmode statement changes the system defaults for locking that are in effect for a session (as defined for the DBMS in CBF). These defaults can be changed for any tables and indexes accessed during the session.
Use the set lockmode statement to optimize performance, alter the level of concurrency, or set locking back to either session or system level.
The set lockmode statement cannot be issued within a transaction, except for the statement:
set lockmode … with timeout=n|session|system|nowait
The following set lockmode parameters control locking for a session:
level
Specifies the level at which locks will be taken. It must be one of the following:
row
Takes row-level locks.
If row-level locking is specified and the number of locks granted during a query exceeds the system lock limit or the number of locks defined for the transaction, locking escalates to table level. This escalation occurs automatically and is independent of the user.
page
(Default) Takes page-level locks.
If page-level locking is specified and the number of locks granted during a query exceeds the system lock limit or the number of locks defined for the transaction, locking escalates to table level. This escalation occurs automatically and is independent of the user.
table
Takes table-level locks.
session
Takes locks according to the default in effect for the session.
system
Starts with page-level locking. If the optimizer estimates that more than maxlocks pages are referenced, escalates to table level locking.
MVCC
Uses multiversion concurrency control, which does not use page or read row locks. For more information, see the chapter on MVCC in the Ingres Database Administrator Guide.
readlock
Specifies the type of locking that applies when accessing a table to read the rows. It does not apply when accessing the table for insert, update, or delete or a table that is the object of an insert ... into select ... from or create table ... as select. Any of the following modes can be specified:
nolock
Takes no locks when reading data.
shared
Takes shared locks when reading data; this is the default mode of locking when reading data.
exclusive
Takes exclusive locks when reading data; useful in “select-for-update” processing within a multi-statement transaction.
session
Takes locks according to the current readlock default for your session.
system
Takes locks according to the readlock default, which is shared.
maxlocks
Specifies the maximum number of logical locks held by a transaction before locking escalates to a table lock. The number of locks available depends on your system configuration. The following escalation factors can be specified:
n
Specifies the number of logical locks to allow before escalating to table level locking. n must be an integer greater than 0.
session
Specifies the current MAXLOCKS default for your session.
system
Specifies the MAXLOCKS default, which is 50.
timeout
Specifies how long, in seconds, a lock request can remain pending. If the DBMS Server cannot grant the lock request within the specified time, the request aborts. Valid settings are:
n
Specifies the number of seconds to wait. n must be an integer between 0 and 2,147,483,647. If 0 is specified, the DBMS Server waits indefinitely for the lock.
nowait
Specifies that when a lock request is made that cannot be granted without incurring a wait, control is immediately returned to the application that issued the request.
session
Specifies the current timeout default for the session.
system
Specifies the default, which is no timeout.