时间:2021-07-01 10:21:17 帮助过:64人阅读
游标共享如何使用Mutex kks 使用mutex以便保护对于下述基于parent cursor父游标和子游标child cursor的一系列操作 对于父游标parent cursor的操作: 基于发生的不同操作,对应不同的等待事件: 在某个父游标名下创建一个新的游标 == cursor:mutex X 检查一个
在版本10.2中, 以下是几个SQL解析与执行从MUTEX哪里获得主要收益:
在某个父游标下构建一个新的子游标Mutex数据结构中存放了Holder id持有者ID , Ref Count,和其他Mutex相关的统计信息。 Holder id对应于持有该Mutex的session id (v$session.sid) 。 特别注意, Ref Count是进程并发以S mode参考该Mutex的进程数量。
当一个Mutex被以X mode 持有,则Holder id 为对应持有该mutex的session id,而Ref Count为0。
每一个共享S mode持有者仅仅增加mutex上的Ref Count。 可供大量session并发以S mode持有参考一个Mutex。 但是注意更新ref count的操作是串行的, 这是为了避免错漏并维护mutex中正确的ref count。
下面我们详细介绍一个执行游标过程中对mutex share pin的过程:
某进程以SHRD 模式申请一个Mutex,并尝试临时修改该Mutex的Holder IDV$MUTEX_SLEEP
shows the wait time, and the number of sleeps for each combination of mutex type and location.
Column | Datatype | Description |
---|---|---|
MUTEX_TYPE | VARCHAR2(32) | Type of action/object the mutex protects |
LOCATION | VARCHAR2(40) | The code location where the waiter slept for the mutex |
SLEEPS | NUMBER | Number of sleeps for this MUTEX_TYPE and LOCATION |
WAIT_TIME | NUMBER | Wait time in microseconds |
V$MUTEX_SLEEP_HISTORY
displays time-series data. Each row in this view is for a specific time, mutex type, location, requesting session and blocking session combination. That is, it shows data related to a specific session (requesting session) that slept while requesting a specific mutex type and location, because it was being held by a specific blocking session. The data in this view is contained within a circular buffer, with the most recent sleeps shown.
Column | Datatype | Description |
---|---|---|
SLEEP_TIMESTAMP | TIMESTAMP(6) | The last date/time this MUTEX_TYPE and LOCATION was slept for by theREQUESTING_SESSION, while being held by the BLOCKING_SESSION. |
MUTEX_TYPE | VARCHAR2(32) | Type of action/object the mutex protects |
GETS | NUMBER | The number of times the mutex/location was requested by the requesting session while being held by the blocking session. GETS is only incremented once per request, irrespective of the number of sleeps required to obtain the mutex. |
SLEEPS | NUMBER | The number of times the requestor had to sleep before obtaining the mutex |
REQUESTING_SESSION | NUMBER | The SID of a session requesting the mutex |
BLOCKING_SESSION | NUMBER | The SID of a session holding the mutex |
LOCATION | VARCHAR2(40) | The code location where the waiter slept for the mutex |
MUTEX_VALUE | RAW(4) | If the mutex is held in exclusive (X) mode, this column shows the SID of the blocking session, else it shows the number of sessions referencing the mutex in S mode. |
P1 | NUMBER | Internal use only |
P1RAW | RAW(4) | Internal use only |
P2 | NUMBER | Internal use only |
P3 | NUMBER | Internal use only |
P4 | NUMBER | Internal use only |
P5 | VARCHAR2(64) | Internal use only. |