Professional Documents
Culture Documents
Session Plan
• Introduction to Concurrency Control
• Compatibility of locks
• Isolation levels
• DB2 Utilities
• SQL Optimizer
In all but one case, DB2 selects the appropriate lock type based
on concurrency control requirements inherent in the transaction.
These locks are called implicit locks. The strategy for implicit
locks is decided during the bind phase.
• PAGE level.
• TABLE level.
• TABLESPACE level.
TSO Environment
EXEC SQL
COMMIT or COMMIT WORK
END-EXEC.
OR
EXEC SQL
ROLLBACK
END-EXEC.
IMS Environment
EXEC SQL
CHKP or XRST
END-EXEC.
OR
EXEC SQL
ROLL or ROLB
END-EXEC.
CICS Environment
EXEC SQL
SYNCPOINT
END-EXEC.
OR
EXEC SQL
ROLLBACK
END-EXEC.
S U X
S Y Y N
U Y N N
X N N N
• Works like a “traffic cop” at the table or table space level and regulate
the use of page level locks and signal to concurrent transactions
whether a particular type of page lock is possible or not.
• This is to regulate the page level locks and signal to other concurrent
transactions whether a particular lock request can be satisfied or not.
• This reduces the processing time to manage the locks while allowing a
high degree of concurrency
– IS (Intent Share)
– IX (Intent Exclusive)
– SIX (Shared with Intent Exclusive)
S U X IS IX SIX
S Y Y N Y N N
U Y N N Y N N
X N N N N N N
IS Y Y N Y Y Y
IX N N N Y Y N
SIX N N N Y N N
• DB2 takes a lock on the page the cursor is accessing and releases the
lock on that page when the cursor moves onto a different page. This is
not done when we use FOR UPDATE OF statement in cursor.
• In RR, DB2 holds all the page locks while the cursor is moving on till
the transaction commits or the thread is deallocated.
• What if a failure occurs after updating 30 salaries? (DB2 only rolls back
the last 5 updations. Why?)
• All the batch programs which splits the job into multiple transactions to
reduce rework, must restart at the point of failure. i.e., the program
must be re- startable
• After every transaction, store the last key (in our case Employee #) in a
separate table known as restart table.
• Should the last key be written just before the COMMIT or just after the
COMMIT?
• A program which is written using this logic always starts from the
restart key (What about the first time?)
• LOAD
• RUNSTATS
• REORG
• When there is an issue in performance and if all the table spaces for
an application are being reorganized, each of the following utility
should be run in sequence.
• Compatibility of locks
• Isolation levels
• DB2 Utilities
• SQL Optimizer