oracle 對比sql語句執行環境
由於執行環境,
子游標無法共享
SQL> select distinct sid from v$mystat;
SID
----------
132
SQL> select distinct sid from v$mystat;
SID
----------
130
SQL> alter session set optimizer_mode=first_rows_10;(130)
Session altered.
SQL> select count(*) from t1;(sid 132)
COUNT(*)
----------
1999
select b.inst_id,b.sql_id,b.child_number.b.plaN_hash_value from gv$sql b where b.sql_text='select count(*) from t1'
#
set linesize 1000
select a.inst_id,b.sql_id ,b.sql_text,b.hash_value,b.child_number,b.plan_hash_value from gv$session a ,gv$sql b where a.sid=&sid and b.hash_value in (a.prev_hash_value)
and a.inst_id=b.inst_id;
SQL> show user
USER is "SYS"
SQL>
SQL> select b.sql_id ,b.sql_text,b.hash_value,b.child_number,b.plan_hash_value from v$session a ,v$sql b where a.sid=&sid and b.hash_value in (a.sql_hash_value,a.prev_hash_value);
SQL_ID SQL_TEXT HASH_VALUE CHILD_NUMBER
------------- ---------------------------------------- ---------- ------------
PLAN_HASH_VALUE
---------------
5bc0v4my7dvr5 select count(*) from t1 4235652837 0
3724264953
SQL> select count(*) from t1;(130)
COUNT(*)
----------
1999
SQL> select b.sql_id ,b.sql_text,b.hash_value,b.child_number,b.plan_hash_value from v$session a ,v$sql b where a.sid=&sid and b.hash_value in (a.sql_hash_value,a.prev_hash_value);
Enter value for sid: 130
old 1: select b.sql_id ,b.sql_text,b.hash_value,b.child_number,b.plan_hash_value from v$session a ,v$sql b where a.sid=&sid and b.hash_value in (a.sql_hash_value,a.prev_hash_value)
new 1: select b.sql_id ,b.sql_text,b.hash_value,b.child_number,b.plan_hash_value from v$session a ,v$sql b where a.sid=130 and b.hash_value in (a.sql_hash_value,a.prev_hash_value)
SQL_ID SQL_TEXT HASH_VALUE CHILD_NUMBER
------------- ---------------------------------------- ---------- ------------
PLAN_HASH_VALUE
---------------
5bc0v4my7dvr5 select count(*) from t1 4235652837 0
3724264953
5bc0v4my7dvr5 select count(*) from t1 4235652837 1
3724264953
執行計劃一樣,plan_hash_value可以看出來,但確產生了 不同的子游標
SELECT name, value, default_value
FROM v$sys_optimizer_env
WHERE isdefault = 'NO';
#查環境變數 哪個不是預設的,針對當前session修改過
SELECT name, value
FROM v$ses_optimizer_env
WHERE sid = 161 AND isdefault = 'NO'
MINUS
SELECT name, value
FROM v$sys_optimizer_env;
#檢視2個不同session環境變數
SQL> SELECT e0.name, e0.value AS value_child_0, e1.value AS value_child_1
2 FROM v$sql_optimizer_env e0, v$sql_optimizer_env e1
3 WHERE e0.sql_id = e1.sql_id
4 AND e0.sql_id = '&sql_id'
5 AND e0.child_number = 0
6 AND e1.child_number = 1
7 AND e0.name = e1.name
8 AND e0.value <> e1.value;
NAME VALUE_CHILD_0
---------------------------------------- -------------------------
VALUE_CHILD_1
-------------------------
optimizer_mode all_rows
first_rows_10
SELECT e0.inst_id,e0.name, e0.value AS value_child_0, e1.inst_id,e1.value AS value_child_1
FROM gv$sql_optimizer_env e0, gv$sql_optimizer_env e1
WHERE e0.sql_id = e1.sql_id
AND e0.sql_id = '&sql_id'
AND e0.child_number = 0
AND e1.child_number = 1
AND e0.name = e1.name
AND e0.value <> e1.value;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12020513/viewspace-665125/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【SQL】Oracle sql語句 minus函式執行效率與join對比SQLOracle函式
- 後臺執行SQL語句(oracle)SQLOracle
- java連線oracle執行sql語句JavaOracleSQL
- 【SQL】Oracle程式設計藝術指令碼學習之runsat(語句執行消耗對比)SQLOracle程式設計指令碼
- Oracle資料庫SQL語句執行過程Oracle資料庫SQL
- 查詢Oracle正在執行的sql語句及執行該語句的使用者OracleSQL
- Oracle執行語句跟蹤 使用sql trace實現語句追蹤OracleSQL
- oracle常用後臺程序及sql語句執行流程OracleSQL
- SQL語句執行順序SQL
- sql語句如何執行的SQL
- 獲取oracle sql語句詳細些執行計劃OracleSQL
- sql語句執行緩慢分析SQL
- mysql的sql語句執行流程MySql
- SQL 語句的執行順序SQL
- mysql執行sql語句過程MySql
- Mybatis 動態執行SQL語句MyBatisSQL
- Oracle基本SQL語句OracleSQL
- Laravel 獲取執行的sql語句LaravelSQL
- MySQL cron定時執行SQL語句MySql
- SQL查詢語句 (Oracle)SQLOracle
- Oracle SQL精妙SQL語句講解OracleSQL
- 不同環境Odoo執行速度對比Odoo
- SQL Server 查詢歷史執行的SQL語句SQLServer
- [20181119]sql語句執行緩慢分析.txtSQL
- SQL語句各子句的執行順序SQL
- mysql sql語句執行超時設定MySql
- Laravel 框架查詢執行的 SQL 語句Laravel框架SQL
- Mybatis原始碼解析之執行SQL語句MyBatis原始碼SQL
- 一條sql語句的執行過程SQL
- 列出oracle dbtime得sql語句OracleSQL
- Oracle行轉列、列轉行的Sql語句總結OracleSQL
- GaussDB SQL查詢語句執行過程解析SQL
- SQL 查詢語句的執行順序解析SQL
- 一條update SQL語句是如何執行的SQL
- python關於pymysql 執行sql語句in的用法PythonMySql
- 一條SQL更新語句是如何執行的SQL
- Hive SQL語句的正確執行順序HiveSQL
- 一條SQL更新語句是如何執行的?SQL
- [ORACLE] SQL執行OracleSQL