3.2 Parent and Child Latches
Most internal Oracle data structures that are protected by latches are protected
by only one latch. However, in some cases more than one latch may be used. For
example, there may be a number of library cache latches protecting different
groups of objects in the library cache, and separate cache buffers chains latches
are used to protect each of the database buffer cache hash chains.
3.2 父latches与子latches
很多被latches保护的内部Oracle数据结构都是仅仅被一个latch保护。然而,在某些情形下有更多的latch被用到。例如,一些library cache latches保护library cache中不同组的objects.单独的cache buffers chains latches保护每个database buffer cache hash chains.Whenever a number of latches may be used to protect different parts of a
structure, or different equivalent structures, these latches are called child latches.
For each set of child latches of the same type there is one parent latch. In general,
both the parent and child latches may be taken. In practice, however, the library
cache parent latch is the only parent latch you are likely to see being taken, and
even then this is a relatively rare occurrence by comparison with the activity against
its child latches.
一些用来保护一种结构的不同部分或different equivalent structures的latches称为子latches。每一组同类型的子latches有一个父latch。通常父latch和子latch都能被获得。然而实际上,the library
cache父latch只是一个你看起来可能被占用的父latch,…………………
Somewhat confusingly, Oracle also refers to solitary latches that have no childrenas parent latches. So the V$LATCH_PARENT view contains one row for each ofthe solitary latches, as well as one row for each of the genuine parent latches.V$LATCH_CHILDREN has a row for each child latch. Thus, the union of thesetwo views represents all latches.
有点令人迷惑不解地,Oracle也提到没有children的solitary latch作为父latches。V$latch_parent试图中每一个单独的latches有一行,和每一个真正的父latch有一行一样。V$latch_children中每一个子latch都有一行,因此,联合这两个试图能知道所有的latches。
The types of latches used by Oracle, and whether they are solitary latches or
parent and child sets, varies with different releases of Oracle and operating
system ports. The APT script latch_types.sql can be used to see what latch types
are in use in your database, whether they are parent and child sets, and if so, how
many child latches there are. Example 3.1 shows an extract of the output of this
script.
Oracle用到的latches的类型,无论solitary latch,父latch和子latch集对不同的ORACLE版本和操作系统是不同的。Latch_types.sql可以看到你的数据库中用到的latch类型,无论是父还是子,和有多少个子latches。Example 3.1是这个脚本的结果。
Example 3.1. Sample Output from latch_types.sql
SQL> @latch_types
------ ------------------------------ ------ -------
0 latch wait list 1 1
1 process allocation 1
2 session allocation 1
3 session switching 1
4 session idle bit 1 1
APT Scripts and X$ Tables
A number of the APT scripts referred to in this book, like latch_types.sql,
are based directly on the X$ tables, rather than the V$ views. This is often
necessary because the V$ views do not contain the required information, or
because querying the V$ views would impose an unsatisfactory load on the
instance.
Because the X$ tables are only visible to the SYS schema, and because it
would be bad practice to do anything as SYS unnecessarily, APT requires
that you create a set of views that expose the X$ tables to other DBA
schemata. This can be done with the create_xviews.sql script, which of
course must be run as SYS. Unless these views exist, all APT scripts that are
dependent on the X$ tables will fail.
Note that the X$ tables change from release to release, and so these APT
scripts are often release specific. Make sure that you use the right scripts for
your release of Oracle.
The V$LATCH view contains summary latch statistics grouped by latch type.
V$LATCH should be your first point of reference when investigating a suspected
latching problem. If the problem relates to a set of latches of the same type, you
should consult V$LATCH_CHILDREN to investigate whether the distribution of
activity across the child latches is even, and possibly V$LATCH_PARENT also to
determine whether there has been any activity against the parent latch.
V$LATCH试图包含了按latch类型分组的latch统计量摘要。V$LATCH应该是当你调查latch问题的第一个参考点。如果问题涉及到一批同类型的latches ,你应该查看v$latch_children………