成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

有關(guān)Oracle邏輯讀和物理讀,你了解嗎?

數(shù)據(jù)庫 Oracle
物理讀即是把數(shù)據(jù)從磁盤讀入到buffer catch的過程。 通常情況下是,如果需要數(shù)據(jù)的時候發(fā)現(xiàn)不存在于buffer catch當(dāng)中,即oracle就會執(zhí)行物理讀。 邏輯讀指的就是從(或者視圖從)Buffer Cache中讀取數(shù)據(jù)塊。按照訪問數(shù)據(jù)塊的模式不同,可以分為即時讀(Current Read)和一致性讀(Consistent Read)。

[[206534]]

1.物理讀(physical read)

物理讀即是把數(shù)據(jù)從磁盤讀入到buffer catch的過程。 通常情況下是,如果需要數(shù)據(jù)的時候發(fā)現(xiàn)不存在于buffer catch當(dāng)中,即oracle就會執(zhí)行物理讀。 

當(dāng)數(shù)據(jù)塊***次讀取到,就會緩存到buffer cache 中,而第二次讀取和修改該數(shù)據(jù)塊時就在內(nèi)存buffer cache 了 以下是例子:

1.1 ***次讀取:

C:\Documents and Settings\Paul Yi>sqlplus "/as sysdba"

SQL*Plus: Release 9.2.0.4.0 - Production on Thu Feb 28 09:32:04 2008

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Connected to:

Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production

With the Partitioning, OLAP and Oracle Data Mining options

JServer Release 9.2.0.4.0 - Production

SQL> set autotrace traceonly

SQL> select * from test;

Execution Plan

----------------------------------------------------------

0 SELECT STATEMENT ptimizer=CHOOSE (Cost=2 Card=4 Bytes=8)

1 0 TABLE ACCESS (FULL) OF 'TEST' (Cost=2 Card=4 Bytes=8)

Statistics

----------------------------------------------------------

175 recursive calls

0 db block gets

24 consistent gets

9 physical reads --9個物理讀

0 redo size

373 bytes sent via SQL*Net to client

503 bytes received via SQL*Net from client

2 SQL*Net roundtrips to/from client

2 sorts (memory)

0 sorts (disk)

1 rows processed

1.2 第二次讀取

SQL> select * from test;

Execution Plan

----------------------------------------------------------

0 SELECT STATEMENT ptimizer=CHOOSE (Cost=2 Card=4 Bytes=8)

1 0 TABLE ACCESS (FULL) OF 'TEST' (Cost=2 Card=4 Bytes=8)

Statistics

----------------------------------------------------------

0 recursive calls

0 db block gets

7 consistent gets

0 physical reads --沒有發(fā)生物理讀了,直接從buffer cache 中讀取了

0 redo size

373 bytes sent via SQL*Net to client

503 bytes received via SQL*Net from client

2 SQL*Net roundtrips to/from client

0 sorts (memory)

0 sorts (disk)

1 rows processed

1.3 數(shù)據(jù)塊被重新讀入buffer cache ,這種發(fā)生在

如果有新的數(shù)據(jù)需要被讀入Buffer Cache中,而Buffer Cache又沒有足夠的空閑空間,Oracle就根據(jù)LRU算法將LRU鏈表中LRU端的數(shù)據(jù)置換出去。當(dāng)這些數(shù)據(jù)被再次訪問到時,需要重新從磁盤讀入。

SQL> alter session set events 'immediate trace name flush_cache'; --清空數(shù)據(jù)緩沖區(qū)

Session altered.

SQL> select * from test;

Execution Plan

----------------------------------------------------------

0 SELECT STATEMENT ptimizer=CHOOSE (Cost=2 Card=4 Bytes=8)

1 0 TABLE ACCESS (FULL) OF 'TEST' (Cost=2 Card=4 Bytes=8)

Statistics

----------------------------------------------------------

0 recursive calls

0 db block gets

7 consistent gets

6 physical reads --又重新發(fā)生了物理讀

0 redo size

373 bytes sent via SQL*Net to client

503 bytes received via SQL*Net from client

2 SQL*Net roundtrips to/from client

0 sorts (memory)

0 sorts (disk)

1 rows processed

2.邏輯讀(buffer read)

邏輯讀指的就是從(或者視圖從)Buffer Cache中讀取數(shù)據(jù)塊。按照訪問數(shù)據(jù)塊的模式不同,可以分為即時讀(Current Read)和一致性讀(Consistent Read)。注意:邏輯IO只有邏輯讀,沒有邏輯寫。

即時讀

即時讀即讀取數(shù)據(jù)塊當(dāng)前的***數(shù)據(jù)。任何時候在Buffer Cache中都只有一份當(dāng)前數(shù)據(jù)塊。即時讀通常發(fā)生在對數(shù)據(jù)進(jìn)行修改、刪除操作時。這時,進(jìn)程會給數(shù)據(jù)加上行級鎖,并且標(biāo)識數(shù)據(jù)為“臟”數(shù)據(jù)。

SQL> select * from test for update;

Execution Plan

----------------------------------------------------------

0 SELECT STATEMENT ptimizer=CHOOSE (Cost=2 Card=4 Bytes=8)

1 0 FOR UPDATE

2 1 TABLE ACCESS (FULL) OF 'TEST' (Cost=2 Card=4 Bytes=8)

Statistics

----------------------------------------------------------

0 recursive calls

1 db block gets

14 consistent gets

0 physical reads

252 redo size

386 bytes sent via SQL*Net to client

503 bytes received via SQL*Net from client

2 SQL*Net roundtrips to/from client

0 sorts (memory)

0 sorts (disk)

1 rows processed

SQL>

一致性讀

Oracle是一個多用戶系統(tǒng)。當(dāng)一個會話開始讀取數(shù)據(jù)還未結(jié)束讀取之前,可能會有其他會話修改它將要讀取的數(shù)據(jù)。如果會話讀取到修改后的數(shù)據(jù),就會造成數(shù)據(jù)的不一致。一致性讀就是為了保證數(shù)據(jù)的一致性。在Buffer Cache中的數(shù)據(jù)塊上都會有***一次修改數(shù)據(jù)塊時的SCN。如果一個事務(wù)需要修改數(shù)據(jù)塊中數(shù)據(jù),會先在回滾段中保存一份修改前數(shù)據(jù)和SCN的數(shù)據(jù)塊,然后再更新Buffer Cache中的數(shù)據(jù)塊的數(shù)據(jù)及其SCN,并標(biāo)識其為“臟”數(shù)據(jù)。當(dāng)其他進(jìn)程讀取數(shù)據(jù)塊時,會先比較數(shù)據(jù)塊上的SCN和自己的SCN。如果數(shù)據(jù)塊上的SCN小于等于進(jìn)程本身的SCN,則直接讀取數(shù)據(jù)塊上的數(shù)據(jù);如果數(shù)據(jù)塊上的SCN大于進(jìn)程本身的SCN,則會從回滾段中找出修改前的數(shù)據(jù)塊讀取數(shù)據(jù)。通常,普通查詢都是一致性讀。

下面這個例子幫助大家理解一下一致性讀:

會話1中:

SQL> select * from test;

ID

----------

1000

SQL> update test set id=2000;

1 row updated.

會話2中:

SQL> set autotrace on

SQL> select * from test;

ID

----------

1000

Execution Plan

----------------------------------------------------------

0 SELECT STATEMENT ptimizer=CHOOSE (Cost=2 Card=4 Bytes=8)

1 0 TABLE ACCESS (FULL) OF 'TEST' (Cost=2 Card=4 Bytes=8)

Statistics

----------------------------------------------------------

0 recursive calls

0 db block gets

9 consistent gets 沒有事物做update時 是 7 consistent gets 說明多了2個 consistent gets 這2個是要從回滾段中獲取的

0 physical reads

52 redo size

373 bytes sent via SQL*Net to client

503 bytes received via SQL*Net from client

2 SQL*Net roundtrips to/from client

0 sorts (memory)

0 sorts (disk)

1 rows processed

SQL> 

責(zé)任編輯:龐桂玉 來源: Oracle疑點通
相關(guān)推薦

2022-03-13 09:31:43

MQ消息隊列ActiveMQ

2019-09-18 17:35:52

2010-10-29 15:37:51

Oracle物理結(jié)構(gòu)

2023-08-09 17:22:30

MVCCMySQL數(shù)據(jù)

2022-03-14 07:53:27

ELTETL大數(shù)據(jù)

2020-06-19 10:07:36

人工智能人臉識別技術(shù)

2022-04-27 07:32:02

臟讀幻讀不可重復(fù)讀

2009-11-17 09:31:06

Oracle Dual

2018-05-11 15:53:59

2019-06-04 14:30:11

大數(shù)據(jù)智慧消防智能

2024-06-04 07:58:31

架構(gòu)本質(zhì)微服務(wù)

2024-04-24 08:26:35

事務(wù)數(shù)據(jù)InnoDB

2021-04-20 19:21:50

臟讀MySQL幻讀

2009-12-08 13:28:43

2022-01-03 07:18:05

臟讀幻讀 MySQL

2022-07-26 00:00:22

HTAP系統(tǒng)數(shù)據(jù)庫

2012-09-06 17:54:28

2014-04-17 16:42:03

DevOps

2009-11-18 13:15:06

Oracle觸發(fā)器

2009-11-20 17:10:43

Oracle B樹索引
點贊
收藏

51CTO技術(shù)棧公眾號

主站蜘蛛池模板: 国产欧美一区二区三区在线看 | 免费a级毛片在线播放 | 日韩中文字幕 | 精品国产91乱码一区二区三区 | 日韩精品视频在线观看一区二区三区 | 国产精品永久在线观看 | 中文字幕亚洲精品在线观看 | 国产丝袜一区二区三区免费视频 | 动漫www.被爆羞羞av44 | 欧美一级免费 | 久草a√| 成人国产免费观看 | 日韩欧美不卡 | 成人在线视频免费看 | 中文字幕一区二区三区在线观看 | 在线免费激情视频 | 亚洲xxxxx| 亚洲二区在线 | 久久九九网站 | 日韩欧美一区二区三区免费看 | 亚洲一区 中文字幕 | 亚洲一区视频 | 亚洲 欧美 激情 另类 校园 | 国产伦精品一区二区三毛 | 久久国产欧美日韩精品 | 亚洲毛片网站 | 国产成人免费视频网站高清观看视频 | 久草新在线 | 亚洲一区二区三区在线视频 | 欧美日日| 精品九九 | 色橹橹欧美在线观看视频高清 | 国产精品国产三级国产aⅴ无密码 | 成人欧美一区二区三区在线播放 | 久久久久久久久国产精品 | 中文字幕在线免费视频 | 亚洲国产精久久久久久久 | 亚洲一区二区久久久 | 欧美成人免费在线 | 久久精品一区二 | 久久精彩视频 |