v$sql_shared_cursor中的BIND_MISMATCH
轉自網路
The advantage of bind variables is that they allow the sharing of cursors in the library cache and that way avoid hard parses and the overhead associated with them. The following example, which is an excerpt of the output generated by the script. bind_variables.sql, shows three INSERT statements that, thanks to bind variables, share the same cursor in the library cache: SQL> variable n NUMBER SQL> variable v VARCHAR2(32) SQL> execute :n := 1; :v := 'Helicon'; SQL> INSERT INTO t (n, v) VALUES (:n, :v); SQL> execute :n := 2; :v := 'Trantor'; SQL> INSERT INTO t (n, v) VALUES (:n, :v); SQL> execute :n := 3; :v := 'Kalgan'; SQL> INSERT INTO t (n, v) VALUES (:n, :v); SQL> SELECT sql_id, child_number, executions 2 FROM v$sql 3 WHERE sql_text = 'INSERT INTO t (n, v) VALUES (:n, :v)'; SQL_ID CHILD_NUMBER EXECUTIONS ------------- ------------ ---------- 6cvmu7dwnvxwj 0 3 There are, however, situations where several child cursors are created even with bind variables. The following example shows such a case. Notice that the INSERT statement is the same as in the previous example. Only the maximum size of the VARCHAR2 variable has changed (from 32 to 33). SQL> variable v VARCHAR2(33) SQL> execute :n := 4; :v := 'Terminus'; SQL> INSERT INTO t (n, v) VALUES (:n, :v); SQL> SELECT sql_id, child_number, executions 2 FROM v$sql 3 WHERE sql_text = 'INSERT INTO t (n, v) VALUES (:n, :v)'; SQL_ID CHILD_NUMBER EXECUTIONS ------------- ------------ ---------- 6cvmu7dwnvxwj 0 3 6cvmu7dwnvxwj 1 1 The new child cursor (1) is created because the execution environment between the first three INSERT statements and the fourth has changed. The mismatch, as can be confirmed by querying the view v$sql_shared_cursor, is because of the bind variables. SQL> SELECT child_number, bind_mismatch 2 FROM v$sql_shared_cursor 3 WHERE sql_id = '6cvmu7dwnvxwj'; CHILD_NUMBER BIND_MISMATCH ------------ ------------- 0 N 1 Y What happens is that the database engine applies the bind variable graduation. The aim of this feature is to minimize the number of child cursors by graduating bind variables (which vary in size) into four groups depending on their size. The first group contains the bind variables with up to 32 bytes, the second contains the bind variables between 33 and 128 bytes, the third contains the bind variables between 129 and 2,000 bytes, and the last contains the bind variables of more than 2,000 bytes. Bind variables of datatype NUMBER are graduated to their maximum length, which is 22 bytes. As the following example shows, the view v$sql_bind_metadata displays the maximum size of a group. Notice how the value 128 is used, even if the variable of child cursor 1 was defined as 33. SQL> SELECT s.child_number, m.position, m.max_length, 2 decode(m.datatype,1,'VARCHAR2',2,'NUMBER',m.datatype) AS datatype 3 FROM v$sql s, v$sql_bind_metadata m 4 WHERE s.sql_id = '6cvmu7dwnvxwj' 5 AND s.child_address = m.address 6 ORDER BY 1, 2; CHILD_NUMBER POSITION MAX_LENGTH DATATYPE ------------ ---------- ---------- ---------------------------------------- 0 1 22 NUMBER 0 2 32 VARCHAR2 1 1 22 NUMBER 1 2 128 VARCHAR2 It goes without saying that each time a new child cursor is created, an execution plan is generated. Whether this new execution plan is equal to the one used by another child cursor also depends on the value of the bind variables. This is described in the next section.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7728585/viewspace-686324/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【CURSOR】Oracle 子游標無法共享的原因之V$SQL_SHARED_CURSOROracleSQL
- VUE中v-for的4中使用方式Vue
- vue中的v-html,v-text,{{}}三種渲染模板VueHTML
- Oracle9i中v$sql、v$sqlarea、v$sqltext、v$sql_plan的聯絡與區別OracleSQL
- vue中v-model的學習Vue
- Linux中的System V訊號量Linux
- [譯]V8引擎中的排序排序
- MTS方式連線V$SESSION中的SERVER狀態SessionServer
- Vue 中的樣式穿透 v-deep、/deep/ 和 >>>Vue穿透
- vs code終端中,無法執行npm -v,nodemon -v等指令的解決方案NPM
- vue v-text,v-html,v-once,v-pre,v-cloak的使用VueHTML
- V8 中更快的非同步函式和 promises非同步函式Promise
- 中興Blade V10跑分多少?中興Blade V10手機效能測試
- v-html 、v-text({{}}) 、v-model的區別HTML
- vue 的v-on與v-bindVue
- v1.9.0 進行中:開箱即用的 MQTT bench 工具MQQT
- vue_o6_v-once、v-html、v-text、v-pre、v-cloak指令的使用VueHTML
- Vue v-if以及 v-else 的使用Vue
- v-if和v-show的區別
- 中斷處理和GIC-V2
- Python 中國象棋原始碼 V1Python原始碼
- AutoCAD 2024 for Mac v2024.3.61.182中文Mac
- vue中v-on繫結多個方法Vue
- 禁用 element 中v-input 自動填充
- 「譯」Liftoff:V8 引擎中全新的 WebAssembly baseline 編譯器Web編譯
- oracle 什麼時候才回收v$session 中status='KILLED'的程式OracleSession
- 關於正在開發中的DjangoStarter v3版本Django
- IdentityServer4 - v4.x .Net中的實踐應用IDEServer
- android之support-v4、v7、v13的區別Android
- v-for的使用
- 銀河麒麟、中標麒麟學習實操資料彙總(含V4、V7、V10)
- 【資料庫】postgresql擷取最後一個字元之前的所有字元,如V1.0.0.20230731110947中取V1.0.0資料庫SQL字元
- React Router從V2/V3到V4的變化React
- webpack v4 中的斷舍離 - 程式碼分離 SplitChunksPlugin(一)WebPlugin
- 怎樣清除v$archived_log檢視中的過期資訊Hive
- 清除Oracle控制檔案中的歸檔資訊v$archived_logOracleHive
- 在 V8 引擎中設定原型(prototypes)原型
- Sketch for Mac v96.1中文版Mac
- (覆盤)Vue中如何使用v-echarts元件VueEcharts元件