Oracle direct path read相關隱含引數
Oracle 10G,預設時,即使對錶全表掃描也會先快取到buffer cache中,parallel方式除外
In 11g or higher, there has a been a change in the rules that choose between using 'direct path reads' and reads through the buffer cache for serial (i.e. non-parallel) table scans. This decision is based on the size of the table, buffer cache size, and various other statistics. Since Direct path reads are faster than scattered reads and have less impact on other processes because they avoid latches, it is likely that they will be chosen for such reads in 11g and above.
Oracle 11G及之後版本,發生了變化,全表掃描可通過直接路徑讀(Direct Path Read)繞開buffer cache方式來執行,是否Direct Path Read取決於table大小,buffer cache大小,其它統計資訊。
由於Direct Path Read比scattered reads快,並且由於避免latch而對其他程式的影響較小,因此11G之後很可能使用Direct Path Read
Oracle direct path read相關引數
_serial_direct_read
是否啟用11G direct path read限制,其預設值為AUTO啟用,設定為NEVER時禁用自動direct path read的特性。該引數可以動態在例項或會話級別修改,而無需重啟例項。
select nam.ksppinm NAME,val.KSPPSTVL VALUE from x$ksppi nam, x$ksppsv val where nam.indx = val.indx and nam.ksppinm = '_serial_direct_read'; alter system set "_serial_direct_read"=auto; alter system set "_serial_direct_read"=never;
_small_table_threshold
預設值為buffer cache的2%, 單位:塊
就是說 table的blocks數大於_small_table_threshold這個值Oracle就認為是大表,就會走 direct path read
select nam.ksppinm NAME,val.KSPPSTVL VALUE from x$ksppi nam, x$ksppsv val where nam.indx = val.indx and nam.ksppinm = '_small_table_threshold';
_direct_read_decision_statistics_driven
11.2.0.2之後出現,預設值為TRUE
select nam.ksppinm NAME,val.KSPPSTVL VALUE from x$ksppi nam, x$ksppsv val where nam.indx = val.indx and nam.ksppinm = '_direct_read_decision_statistics_driven';
When the above parameter is FALSE, the direct path read decision is done based on the actual block count of segment header.
When the above parameter is TRUE (default from 11.2.0.2), the direct path read decision is done based on the optimizer statistics.
TRUE: 代表走direct path read的判定,基於table的統計資訊。
比如:
(1) SQL> SELECT blocks FROM user_tables WHERE table_name = 'TABLE_NAME';
Example:
If the blocks from user_tables for the object show 100 and _small_table_threshold is set to 480 then set the blocks statistics manually to 1000 so that it would go for direct path read.
(2) Set the no.of blocks statistics for the tables involved in the SQL manually greater than the "_small_table_threshold" value.
SQL> EXEC DBMS_STATS.SET_TABLE_STATS('username','tabname',numblks=>n);
Example:
SQL> EXEC DBMS_STATS.SET_TABLE_STATS(user,'TEST',numblks=>1000);
統計資訊查詢TABLE有100個block小於_small_table_threshold 480話,就不會走direct path read。如果統計資訊block設定超過480話就會走direct path read
FLASE: 代表走direct path read的判定,基於table segment header實際的block數
10949 事件
通過設定10949事件遮蔽direct path read特性,返回到Oracle 10G及之前的模式:
alter session set events '10949 trace name context forever, level 1';
還有一個引數 _very_large_object_threshold 用於設定(MB單位)使用DPR(
direct path read)方式的上限,這個引數需要結合10949事件共同發揮作用。
10949 事件設定任何一個級別都將禁用DPR的方式,但是僅限於小於 5 倍 BUFFER Cache的資料表,同時,如果一個表的大小大於 0.8 倍的 _very_large_object_threshold 設定,也會執行DPR。
這些限定的目標在於:
對於大表的全表掃描,必須通過Direct Path Read方式執行,以減少對於Buffer Cache的衝擊和效能影響。
但是我們可以通過引數調整來決定執行DPR的上限和下限。
Event 10949 可以線上設定,但對現有session可能不會生效,新登入的會話會執行新的設定:
在例項級別修改引數設定:
ALTER SYSTEM SET EVENTS '10949 TRACE NAME CONTEXT FOREVER';
增加引數到SPFILE中:
alter system set event='10949 TRACE NAME CONTEXT FOREVER' scope=spfile;
對當前會話設定:
ALTER SESSION SET EVENTS '10949 TRACE NAME CONTEXT FOREVER';
參考:
https://www.eygle.com/archives/2012/05/oracle_11g_direct_path_read.html
How To Force Direct Path Read for SQL Statements (Doc ID 2426051.1)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25583515/viewspace-2691395/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【PARANETERS】Oracle異常恢復相關的隱含引數Oracle
- direct path read/read temp等待事件事件
- 【TUNE_ORACLE】等待事件之IO等待“direct path read”Oracle事件
- [20180905]lob與direct path read.txt
- [20191204]hugepage相關引數含義.txt
- [20220913]hugepage相關引數含義.txt
- Oracle 11G 隱含引數“_controlfile_autobackup_delay”Oracle
- Oracle安裝相關Linux引數(轉)OracleLinux
- 【TUNE_ORACLE】等待事件之IO等待“direct path write”Oracle事件
- [20190417]隱含引數_SPIN_COUNT.txt
- 常用指令碼:獲取隱含引數指令碼
- 【TUNE_ORACLE】等待事件之IO等待“direct path write temp”Oracle事件
- Oracle undo保留時間的幾個相關引數Oracle
- pga相關引數
- [20190401]隱含引數_mutex_spin_count.txtMutex
- MySQL效能相關引數MySql
- PostgreSQL AutoVacuum 相關引數SQL
- v$parameter gv$parameter 檢視 DDL 與隱含引數
- [20191206]隱含引數_db_always_check_system_ts.txt
- Spark的相關引數配置Spark
- MySQL 連線相關引數MySql
- 資料庫管理-第123期 Oracle相關兩個引數(202301205)資料庫Oracle
- 等待事件db file sequential read、db file scattered read和direct read的區別事件
- 使用隱含引數testMappingSpeed排查GoldenGate抽取慢的步驟APPGo
- ORACLE並行相關的引數Oracle並行
- Oracle11g 自動化建庫及調整相關引數Oracle
- 4.2.10.1 Oracle Restart 相關變數配置OracleREST變數
- 關於 Express API app.use 中的 path 引數用法ExpressAPIAPP
- mysql relay log相關引數說明MySql
- redis持久化相關引數解釋Redis持久化
- openGauss執行緒池相關引數執行緒
- 關於隱藏引數:_no_recovery_through_resetlogs
- Pandas read_csv 引數詳解
- Oracle相關命令Oracle
- PostgreSQL並行查詢相關配置引數SQL並行
- [20200420]V$SES_OPTIMIZER_ENV 查不到剛修改的隱含引數.txt
- MySQL:Innodb Handler_read_*引數解釋MySql
- 【測試】Android Studio 相關下載及引數Android