Query Optimizer  «Prev  Next»

Monitoring Oracle Performance

  1. EXPLAIN PLAN: Used to provide a step-by-step exposition of the execution plan
  2. TKPROF: Works off of statistics gathered with the Trace utility
  3. V$SESSION_LONGOPS: Real-time information about operations such as backup and recovery
  4. Oracle Enterprise Manager: Multifaceted tool for gathering information about the operations of your Oracle database.

Locks in data blocks

A database must have a way of determining if a particular row is locked. Most databases keep a list of locks in memory, which are managed by a lock manager process. Oracle keeps locks with an area of the actual block in which the row is stored. A data block is the smallest amount of data that can be read from disk for an Oracle database, so whenever the row is requested, the block is read, and the lock is available within the block. Although the lock indicators are kept within a block, each lock affects only an individual row within the block.

Monitoring Locks

Locks are mechanisms that prevent destructive interaction between transactions accessing the same resource. The resources can be either user objects, such as tables and rows, or system objects not visible to users, such as shared data structures in memory and data dictionary rows. Oracle Database automatically obtains and manages necessary locks when executing SQL statements, so you need not be concerned with such details. However, the database also lets you lock data manually.
A deadlock can occur when two or more users are waiting for data locked by each other. Deadlocks prevent some transactions from continuing to work. Oracle Database automatically detects deadlock situations and resolves them by rolling back one of the statements involved in the deadlock, thereby releasing one set of the conflicting row locks.
Oracle Database is designed to avoid deadlocks, and they are not common. Most often they occur when transactions explicitly override the default locking of the database. Deadlocks can affect the performance of your database, so Oracle provides some scripts and views that enable you to monitor locks.
The utllockt.sql script displays, in a tree fashion, the sessions in the system that are waiting for locks and the locks that they are waiting for. The location of this script file is operating system dependent. A second script, catblock.sql, creates the lock views that utllockt.sql needs, so you must run it before running utllockt.sql.
In the next lesson, you will learn how database statistics, the basis of all cost calculations, are collected.