Mainframe Path Start learning free
Applied12 min readLesson 3 of 3

Buffer pools, locking, data sharing and troubleshooting

DB2 performance depends on how well data is cached in buffer pools, how much programs block each other with locks, and, in a data sharing group, how members coordinate through the coupling facility. Accounting and statistics traces tell you where the time is really going.

Buffer pools

A buffer pool is an area of memory where DB2 caches table and index pages. A getpage is a request for a page; if it is not in the pool, DB2 must read it from disk, a synchronous read that the program waits for. Prefetch reads pages ahead in the background for sequential and list access.

Locking and concurrency

DB2 uses the IRLM lock manager to stop programs from changing data others are using. Locks are taken at the size set by the table space's LOCKSIZE (ANY, PAGE, ROW, TABLE or TABLESPACE) and held according to the isolation level and when the program commits.

ProblemWhat happensTypical signs
TimeoutA program waits longer than the site's timeout limit for a lockSQLCODE -911 or -913, reason 00C9008E, message DSNT376I
DeadlockTwo programs each hold a lock the other needs; DB2 picks a victimSQLCODE -911 or -913, reason 00C90088, message DSNT375I
Lock escalationToo many page or row locks on one object, so DB2 takes one table space lockMessage DSNI031I; other programs suddenly wait

The main tuning levers are in the application as much as in DB2:

Data sharing, at concept level

In data sharing, several DB2 subsystems (members) in a Parallel Sysplex share the same databases. Work can run on any member, so a member can be stopped for maintenance while others continue.

A two-member data sharing group
Members
DB2A on LPAR 1DB2B on LPAR 2Each has its own logs and local buffer pools
Coupling facility
Lock structure: global lockingGroup buffer pools: changed pages shared between membersShared communications area (SCA)
Shared disk
One catalog and directoryThe same table spaces and indexesEach member's logs readable by the others

Data sharing adds global locking and coherency overhead, so lock contention and group buffer pool sizing become tuning topics. If a member fails, its locks become retained locks that protect uncommitted changes until the member restarts, so restarting a failed member quickly matters.

Troubleshooting performance

DB2 writes trace data to SMF: accounting records (type 101) per thread or transaction, statistics records (type 100) for the subsystem, and performance traces (type 102) for detailed problems. Monitors such as IBM OMEGAMON for Db2, BMC AMI and Broadcom tools format them.

Accounting timeMeans
Class 1 elapsedTotal time of the thread, in the application and in DB2
Class 2 elapsedTime spent inside DB2
Class 3 suspensionsTime inside DB2 spent waiting: lock waits, synchronous I/O, log writes, and so on

Compare them: if class 2 is small against class 1, the time is in the application or elsewhere, not DB2. If class 3 is high, its breakdown shows whether you are waiting on locks or I/O. High class 2 CPU points to access paths: go back to EXPLAIN.

Common mistakes

Judging a buffer pool by hit ratio alone

A good ratio can hide a few objects doing heavy synchronous I/O. Look at synchronous reads per object and per second, not just the overall percentage.

Fixing timeouts by raising the timeout value

A longer wait only hides the holder. Find the program holding the lock and why it does not commit.

Using UR everywhere to avoid locking

Uncommitted read can return data that is later rolled back. Use it only where the business accepts that, such as rough counts.

What you will see at work

Key terms

Check your understanding.
Take this lesson's quiz and save your progress. Free.

Take the lesson quiz
← Utilities, backup and recoveryBack to Advanced DB2