您的位置:首页 > 产品设计 > UI/UE

How to Determine The Lock Type and Mode from an Enqueue Wait

2017-06-15 09:04 691 查看

Applies to:

Oracle Server - Enterprise Edition -Version: 8.1.7.4 to 10.2.0.4

Information in this document applies to any platform.

Goal

Determining the type of enqueue and the mode its beingheld is key to investigating enqueue wait bottlenecks.  This isstraightforward in 10g or higher, but requires more analysis in earlierversions.  This note will show you how to analyze 10046 / TKProf and
AWR /statspack reports to determine the lock type and mode held. 

@ This note doesn't add much beyond others such as note<34566.1> but is written specifically for use in the PerformanceDiagnostic Guide.  Hopefully, its of some use outside of it as well.

Solution

TKProf

This technique will show you the lock type and mode held aswell as the top SQL statements that are seeing these waits.

In the "Overall Totals" section, look for wait events with high elapsed times for "enq:" (10g) or "enqueue" (pre-10g) events (Overall Totals, recursive and non-recursive)

In the "Overall Totals" section, determine which call type is associated with the highest elapsed time: parse, execute, or fetch

Generate a new TKProf report sorted by the call type found for the highest elapsed times. For example:

Execute calls:
tkpof trace_file_name output_file sort=exeela

Fetch calls:

tkpof trace_file_name output_file sort=fchela

Choose a few of the top cursors in this new TKProf report and find them in the original trace file.

Oracle 10g+: Examine the waits for the statement and see which "enq" wait it is.  E.g.,
enq: TX - row lock contention
Oracle versions prior to 10g: Older versions of Oracle had less detail for some enqueue types like TX; 10g gives precise reasons for the TX enqueue. The following steps show how to decode the enqueue type and mode:
Look at the lines with "WAIT #" for the enqueue event corresponding to the cursor and find the value of the "P1" field. This field corresponds to the
enqueue type and mode.
Convert the P1 value to hexadecimal from decimal
The first four digits can be separated as 2 pairs of hex numbers. Each pair is an ASCII code for the lock type.

For example:

4.  WAIT #1: nam='enqueue' ela= 3007866 p1=1414332419 p2=30152 p3=0

The P1 value is 1414332419 which in hex is544D0003, the first four digits are: 54 and 4D.

54 hex = "T" in ASCII

4D hex = "M" in ASCII

So, this is a "TM" lock type.

The last digit is the lock mode that is being requested. The modes are:

0 - none
1 - null (NULL)
2 - row-S (SS)
3 - row-X (SX)
4 - share (S)
5 - S/Row-X (SSX)
6 - exclusive (X)

Iin this case, the requested lock mode is 3 or Row-X (row exclusive lock).

Now, you can get an idea of which enqueue types and modes are causing most of the waits. .

AWR or statspack report

An AWR or statspack report will give you an idea of whichenqueue is causing problems but you will not know the mode its held or exactlywhich SQL statement is associated with the waits.  Nevertheless, here aresome helpful tips:

10g or higher; the enqueue wait will include which enqueue is causing the wait and why. E.g.,
enq: TX - row lock contention
9.0.x - 9.2.x, the wait will be enqueue. You'll have to visit the
Enqueue Activities section and find the enqueue with the highest wait times.

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐