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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- v$sql v$sqlarea v$sql_shared_cursor及遊標SQL
- V$SQL_SHARED_CURSOR檢視硬解析的原因SQL
- cursor_sharing與v$sqlarea_v$sql_v$sql_shared_cursorSQL
- v$sql v$sqlarea v$sql_shared_cursor及父遊標,子游標SQL
- sql執行計劃_v$sqlarea_v$sql_v$sql_shared_cursorSQL
- v$sql_shared_cursor檢視記錄多版本的資訊SQL
- 【CURSOR】Oracle 子游標無法共享的原因之V$SQL_SHARED_CURSOROracleSQL
- sql_shared_cursor (轉)SQL
- 檢視v$sql_shared_cursor檢視獲取sql語句為什麼不能共享?SQL
- v$session中的serverSessionServer
- 關於v$process與v$session中process的理解Session
- 【SESSION】v$session and v$license 中sessions_current 的區別Session
- Oracle V$SESSION中的常用列OracleSession
- v$datafile中的last_change#AST
- VUE中v-for的4中使用方式Vue
- V$SESSION中的saddr,paddr,taddr 與v$process及v$transaction中欄位的關係Session
- vue中的v-html,v-text,{{}}三種渲染模板VueHTML
- Oracle9i中v$sql、v$sqlarea、v$sqltext、v$sql_plan的聯絡與區別OracleSQL
- vue中v-model的學習Vue
- v$access中查詢呼叫的objectObject
- v$process和v$session中欄位解釋Session
- [筆記]解析v$log/v$logfile中status列值的含義筆記
- Linux中的System V訊號量Linux
- 顯示v$sqltext中完整的sql資訊SQL
- [譯]V8引擎中的排序排序
- v$lock.type中的內容解釋
- V$動態效能表中的孿生兄弟~~
- WebSphere Integration Developer V6.2 中的新增功能WebDeveloper
- WebSphere Business Monitor V6.2 中的新增功能Web
- MTS方式連線V$SESSION中的SERVER狀態SessionServer
- Vue 中的樣式穿透 v-deep、/deep/ 和 >>>Vue穿透
- V8 中的垃圾收集(GC),圖文指南GC
- v$session中command欄位的含義解析Session
- V$ACTIVE_SESSION_HISTORY 檢視中包含的資訊Session
- IBM Lotus Forms V3.0 中的新特性IBMORM
- WebSphere Message Broker V6.1 中的新增功能Web
- WebSphere Business Modeler V6.2 中的新增功能Web
- WebSphere Integration Developer V7 中的 XML 對映WebDeveloperXML