decose oracle_oracle 内存与进程
shared pool
1 庫緩存 library cache
游標和pl/sql游標不是一個概念
hashset
在找bucket
根據shared_pool_size 指定的尺寸,可以計算出bucket個數
每一個bucket都有一個對象制定
2 數據字典緩沖
內存塊組成 chunk
chunk是shared pool 中內存分配的最小單元,在內存中是連續的
chunk分類
1. free 2.recreatable 3.freeable 4. perm
一條sql語句
1.進入共享池 shared pool
2.轉為為ascii值
3.對ascii 進行hash運算,得到一個數值(對應的bucket的號碼)
對bucket進行遍歷,遍歷bucket 的時候,
有:直接返回可以使用的sql
沒有:獲取shared pool latch,硬解析開始。
硬解析的過程:
1 對sql語句進行 語法檢查, 如果有錯,馬上退出。
select * form emps
2 檢查sql語句涉及到的對象是否存在
3 檢查權限
4 獲取free bucket中當空的chunk以及相關的latch
5 通過優化器,創建執行計劃,最優的。
6 執行計劃以及sql文本進入 library cache,在解析的過程中,
進程一直持有library cache的latch,一直到硬解析結束。
軟解析:
1.
A select * from emp;
B select * from emp; 省略5 ?6
2.
A select * from emp;
select * from emp;省略2 4 5 6
4.將對象放進對應的bucket中
SQL 語句解析過程
select * from emp where empno=7369
硬解析
軟解析
latch 閂鎖
1.latch 是保護 鏈的
2.簡單 只有兩個狀態 0 1 內存鎖
latch 是保護 鏈的,不是保護數據的
要訪問修改 鏈,首先有鏈的latch
latch爭用
例子:
2 cpu
A 進程
B 進程
C 進程
A進程 獲取到CPU時間片 讀取鏈 需要獲取latch 將0改為1
B進程 獲取到另一個CPU,B去讀取這個鏈
B有兩種選擇:
1 馬上退出CPU 讓其他進程工作 ====》 C進程進入CPU
2 B進程知道這時一個閂鎖 latch,知道很快就被釋放,在CPU等會。閂自旋 空轉CPU。
嘗試3次,如果嘗試3次之后,還沒有等到latch,退出CPU.
發現shared pool latch 被大量爭用,說明有 大量的sql語句, 需要被硬解析,
select * from emp where empno=7369
select ?* from emp where empno=7369
父子游標
一條sql被解析,被解析后,放到庫緩存中。產生父游標和子游標
父:sql語句 ? ? ? 比較小
子:執行計劃 ? ? ?比較大
select * from emp where id=1;
select * from emp where id=10000;
記住:
動態性能視圖:
v$sql 每一行 ?對應一個子游標
v$sqlarea 每一行 對應一個父游標
游標在硬解析結束后
當session 打開游標以后,就會鎖定父游標。
oracle 根據父游標 構建子游標 reload
1 顯示shared pool 中的自由空間
desc v$sgastat
select * from v$sgastat where name='free memory'
show parameter shared_pool_size;
alter system set shared_pool_size=100M;
select * from v$librarycache
select * from v$sysstat where name='parse count(hard)'
shared_pool 的sql命中率
1 hash value
2 有的話 軟解析
3 沒有 硬解析
4
查詢命中率
select ?namespace,pins,pinhists,reloads,invalidations from v$librarycache ;
select sum(pinhits)/sum(pins) from v$libraryccache
execute dbms_stats.gather_table_stats()
分享到:
2011-09-30 08:59
瀏覽 960
分類:數據庫
評論
總結
以上是生活随笔為你收集整理的decose oracle_oracle 内存与进程的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python中提供怎样的内置库、可以用来
- 下一篇: 数据库access和mysql_数据库a