Consistent Gets(就是logical read)+ DB Block Gets = 所謂的Logical Reads

哎呀我的天吶發表於2015-03-12
consistent gets :db buffer cache中的塊被訪問的次數,不管你是CR塊還是普通的塊。只要被訪問一次,consistent gets就加1,
SQL>show arraysize
15
顯示了一次返回行數的限制,比如說一個塊中有1000行資料,我要全部邏輯讀這1000條資料需要1000/15 次。如果set arraysize 1000 那麼就需要一次邏輯讀。
它表示從Oracle伺服器端一次只傳遞15行記錄到客戶端(SQLPLUS),當然了JDBC,WEBLOGIC也有行預取,具體自己Google
db block gets : db buffer cache被更改了,計數加1。

SQL> alter system flush buffer_cache;
系統已更改。

SQL> set autot

用法: SET AUTOT[RACE] {OFF | ON | TRACE[ONLY]} [EXP[LAIN]] [STAT[ISTICS]]
SQL> set autot traceonly stat


SQL> select * from t
已選擇798945行。
統計資訊

----------------------------------------------------------
1 recursive calls
0 db block gets --這個為0
63677 consistent gets
11118 physical reads
0 redo size
85740332 bytes sent via SQL*Net to client
586267 bytes received via SQL*Net from client
53264 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
798945 rows processed


SQL> select * from t;
已選擇798945行。

統計資訊
----------------------------------------------------------
0 recursive calls
0 db block gets
69587 consistent gets --全是一致性得到,因為已經在Buffer cache中
0 physical reads
0 redo size
85740332 bytes sent via SQL*Net to client
586267 bytes received via SQL*Net from client
53264 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
798945 rows processed

SQL> select * from t for update;
已選擇798945行。

統計資訊
----------------------------------------------------------
476 recursive calls
812439 db block gets --更新時,產生這個
884932 consistent gets
5 physical reads
160912940 redo size
73057198 bytes sent via SQL*Net to client
586267 bytes received via SQL*Net from client
53264 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
798945 rows processed

SQL> rollback;
回退已完成。


SQL> alter system flush buffer_cache;
系統已更改。

SQL> select * from t for update;

已選擇798945行。


統計資訊
----------------------------------------------------------
476 recursive calls
812437 db block gets
884836 consistent gets
11122 physical reads
160903012 redo size
73057198 bytes sent via SQL*Net to client
586267 bytes received via SQL*Net from client
53264 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
798945 rows processed


SQL> alter system flush buffer_cache;
系統已更改。


SQL> desc t;
名稱 是否為空? 型別
----------------------------------------- -------- ---------------------------

OWNER VARCHAR2(30)
OBJECT_NAME VARCHAR2(128)
SUBOBJECT_NAME VARCHAR2(30)
OBJECT_ID NUMBER
DATA_OBJECT_ID NUMBER
OBJECT_TYPE VARCHAR2(19)
CREATED DATE
LAST_DDL_TIME DATE
TIMESTAMP VARCHAR2(19)
STATUS VARCHAR2(7)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)

SQL> update t set owner='a';

已更新798945行。


統計資訊
----------------------------------------------------------
4564 recursive calls
7008787 db block gets
1123165 consistent gets
13434 physical reads
555747124 redo size
683 bytes sent via SQL*Net to client
558 bytes received via SQL*Net from client
4 SQL*Net roundtrips to/from client
16 sorts (memory)
0 sorts (disk)
798945 rows processed


SQL> select * from t;
已選擇798945行。

統計資訊
----------------------------------------------------------
1 recursive calls
0 db block gets
63677 consistent gets
0 physical reads
0 redo size
82886810 bytes sent via SQL*Net to client
586267 bytes received via SQL*Net from client
53264 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
798945 rows processed

可以理解 為:
consistent gets : 是由查詢語句產生的,不管所查的資料是否需要構造前映象,都要算進去
db block gets: 是由update,delete,select for update 產生的

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29990276/viewspace-1456970/,如需轉載,請註明出處,否則將追究法律責任。

相關文章