v$sql
v$sql 列出统计信息在shared SQL areas 没有GROUP BY 字句,
每行包含每个原始SQL文本的每个child
v$sql 显示的统计信息是通常更新在查询执行尾端。
v$sqlarea:
v$sqlarea
v$sqlarea 显示统计信息在恭喜SQL区域,每个SQL语句 一行
测试1:
先清空shared pool:
SQL> alter system flush shared_pool;
System altered.
SQL> select count(*) from v$sql;
COUNT(*)
----------
51
SQL> select count(*) from v$sqlarea;
COUNT(*)
----------
86
SQL> alter system flush shared_pool;
System altered.
create unique index KLNL_DKKHMX_IDX1 on KLNL_DKKHMX (MINGXIBH, DKJIEJUH, FARENDMA);
create index KLNL_DKKHMX_IDX3 on KLNL_DKKHMX (DKJIEJUH, FARENDMA);
select nvl(max(to_number(mingxibh)), 0) as lMaxXuhao from klnl_dkkhmx
where dkjiejuh='2018062700000655'
and farendma='9999' and
trim(translate(mingxibh,'0123456789',' ')) is null;
SQL> explain plan for select nvl(max(to_number(mingxibh)), 0) as lMaxXuhao
from klnl_dkkhmx
where dkjiejuh = '20151020000935'
and farendma = '9999'
and trim(translate(mingxibh, '0123456789', ' ')) is null; 2 3 4 5
Explained.
SQL> select * from table(dbms_xplan.display());
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 898418289
-------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 46 | 5 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 46 | | |
|* 2 | TABLE ACCESS BY INDEX ROWID| KLNL_DKKHMX | 1 | 46 | 5 (0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | KLNL_DKKHMX_IDX3 | 2 | | 3 (0)| 00:00:01 |
-------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter(TRIM(TRANSLATE("MINGXIBH",'0123456789',' ')) IS NULL)
3 - access("DKJIEJUH"='20151020000935' AND "FARENDMA"='9999')
16 rows selected.
SQL> col sql_text format a20
SQL> select sql_id,sql_text,version_count,loads,hash_value,address,plan_hash_value,old_hash_value, last_active_child_address from v$sqlarea a where a.sql_id='67wvhym3apr0k';
SQL_ID SQL_TEXT VERSION_COUNT LOADS HASH_VALUE ADDRESS PLAN_HASH_VALUE OLD_HASH_VALUE LAST_ACTIVE_CHIL
------------- -------------------- ------------- ---------- ---------- ---------------- --------------- -------------- ----------------
67wvhym3apr0k select nvl(max(to_nu 1 1 3333086226 00000000E0220A88 898418289 1481984114 00000000E0722260
mber(mingxibh)), 0)
as lMaxXuhao from
klnl_dkkhmx where d
kjiejuh = '201510200
00935' and farend
ma = '9999' and t
rim(translate(mingxi
bh, '0123456789', '
')) is null
SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR('67wvhym3apr0k',0));
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID 67wvhym3apr0k, child number 0
-------------------------------------
select nvl(max(to_number(mingxibh)), 0) as lMaxXuhao from klnl_dkkhmx
where dkjiejuh = '20151020000935' and farendma = '9999' and
trim(translate(mingxibh, '0123456789', ' ')) is null
Plan hash value: 898418289
-------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 5 (100)| |
| 1 | SORT AGGREGATE | | 1 | 46 | | |
|* 2 | TABLE ACCESS BY INDEX ROWID| KLNL_DKKHMX | 1 | 46 | 5 (0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | KLNL_DKKHMX_IDX3 | 2 | | 3 (0)| 00:00:01 |
-------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter(TRIM(TRANSLATE("MINGXIBH",'0123456789',' ')) IS NULL)
3 - access("DKJIEJUH"='20151020000935' AND "FARENDMA"='9999')
23 rows selected.
SQL> select sql_id,a.sql_text, a.LOADED_VERSIONS,a.hash_value,a.ADDRESS,a.OLD_HASH_VALUE,a.plan_hash_value,a.child_number, a.child_address from v$sql a where a.sql_id='67wvhym3apr0k';
SQL_ID SQL_TEXT LOADED_VERSIONS HASH_VALUE ADDRESS OLD_HASH_VALUE PLAN_HASH_VALUE CHILD_NUMBER CHILD_ADDRESS
------------- -------------------- --------------- ---------- ---------------- -------------- --------------- ------------ ----------------
67wvhym3apr0k select nvl(max(to_nu 1 3333086226 00000000E0220A88 1481984114 898418289 0 00000000E0722260
mber(mingxibh)), 0)
as lMaxXuhao from
klnl_dkkhmx where d
kjiejuh = '201510200
00935' and farend
ma = '9999' and t
rim(translate(mingxi
bh, '0123456789', '
')) is null
SQL> set linesize 200
SQL> explain plan for select /*+INDEX(klnl_dkkhmx KLNL_DKKHMX_IDX1)*/ nvl(max(to_number(mingxibh)), 0) as lMaxXuhao
from klnl_dkkhmx
where dkjiejuh = '20151020000935'
and farendma = '9999'
and trim(translate(mingxibh, '0123456789', ' ')) is null;
2 3 4 5
Explained.
SQL> select * from table(dbms_xplan.display());
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 4239695997
-------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 46 | 1766 (0)| 00:00:22 |
| 1 | SORT AGGREGATE | | 1 | 46 | | |
|* 2 | INDEX SKIP SCAN| KLNL_DKKHMX_IDX1 | 1 | 46 | 1766 (0)| 00:00:22 |
-------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("DKJIEJUH"='20151020000935' AND "FARENDMA"='9999')
filter("DKJIEJUH"='20151020000935' AND
TRIM(TRANSLATE("MINGXIBH",'0123456789',' ')) IS NULL AND "FARENDMA"='9999')
16 rows selected.
SQL> col sql_text format a100
SQL> select sql_text,sql_id from v$sqlarea a where a.sql_text like '%klnl_dkkhmx%';
SQL_TEXT SQL_ID
---------------------------------------------------------------------------------------------------- -------------
select /*+INDEX(klnl_dkkhmx KLNL_DKKHMX_IDX1)*/ nvl(max(to_number(mingxibh)), 0) as lMaxXuhao from brc3fx39un2ft
klnl_dkkhmx where dkjiejuh = '20151020000935' and farendma = '9999' and trim(translate(mingx
ibh, '0123456789', ' ')) is null
select nvl(max(to_number(mingxibh)), 0) as lMaxXuhao from klnl_dkkhmx where dkjiejuh = '201510200 67wvhym3apr0k
00935' and farendma = '9999' and trim(translate(mingxibh, '0123456789', ' ')) is null
select sql_id,sql_text,version_count,loads,hash_value,address,plan_hash_value,old_hash_value, last_a 9aw6mstmg9x22
ctive_child_address from v$sqlarea a where a.sql_text like '%klnl_dkkhmx%'
select * from v$sqlarea a where a.sql_text like '%klnl_dkkhmx%' 4sawk3nuxk59t
explain plan for select nvl(max(to_number(mingxibh)), 0) as lMaxXuhao from klnl_dkkhmx where dkji 1xckyuaumyvmz
ejuh = '20151020000935' and farendma = '9999' and trim(translate(mingxibh, '0123456789', ' '))
is null
select sql_text,sql_id from v$sqlarea a where a.sql_text like '%klnl_dkkhmx%' c1hbcgaqdb3hr
select sql_text,version_count,loads,hash_value,address,plan_hash_value,old_hash_value, last_active_c 076nfx1q63gbw
hild_address from v$sqlarea a where a.sql_text like '%klnl_dkkhmx%'
10 rows selected.