|
原帖由 netbanker 于 2010-6-2 01:57 发表
i believe generally speaking hash_value and sql_id can all point to the unique sql in oralce, but hash_value is used for backward compatibility plus all library cache still uses it. but in each sql_id you may have different plan_hash_value based on various plan.
as viadeazhu mentioned, SQL_EXEC_ID is just a key relation with V$SQL_MONITOR. SQL_ID+ SQL_CHILD_NUMBER could be used more precisely to point the specific sql text + cursor plan
我不认为hash_value或者sql_id能定位“unique SQL”,只能说能定位unique sqltext,因为hash_value和sql_id都是根据一个sql_text算出来的。
不过我同意“SQL_ID+ SQL_CHILD_NUMBER could be used more precisely to point the specific sql text + cursor plan ”
如果我们有两个不同的schema下有个同名的table,然后分别run两个一样的SQL TEXT:
SQL> conn hao/hao
Connected.
SQL> select count(*) from testbyhao;
COUNT(*)
----------
36350
SQL> select count(*) from testbyhao;
COUNT(*)
----------
36350
SQL> conn haozhu_user/haozhu_user
Connected.
SQL> select count(*) from testbyhao;
COUNT(*)
----------
36349
其实这是两个SQL,不过具有相同的sql text而已。
于是在v$sql中有两条记录,都具有相同的sql_id和sql_text。
SQL> select SQL_TEXT,SQL_ID,EXECUTIONS,CHILD_NUMBER from v$sql where HASH_VALUE=4189264772;
SQL_TEXT
--------------------------------------------------------------------------------
SQL_ID EXECUTIONS CHILD_NUMBER
------------- ---------- ------------
select count(*) from testbyhao
45xbbz7wv66w4 2 0
select count(*) from testbyhao
45xbbz7wv66w4 1 1 |
|