从v$sql 里取出child_number,sql_id
select t.sharable_mem,t.buffer_gets,t.DISK_READS,t.rows_processed,t.SORTS,t.EXECUTIONS,t.CPU_TIME/1000000,t.ELAPSED_TIME/1000000,
--t.PHYSICAL_READ_BYTES, --11g里才有,10g没有,physical_write_bytes一样。
t.child_number
from v$sql t where sql_id='4pn7guqhvxjbn'
这里需要注意的有:
cpu_time和elapsed_time,在单线程情况下:elapsed_time=cpu_time+wait_time,但在多核情况下:
CPU Time:对于单线程程序来说,CPU TIME指的是该线程在一个逻辑处理器(单核)上所花费的时间总量;对于多线程程序来说,CPU TIME指的是所有线程的CPU TIME之和;应用程序的CPU时间指的是该程序所有线程的CPU TIME之和。
Wait Time:特定线程等待一定事件发生的时间,这些事件可以是同步等待,I/O等待。
Elapsed time:该程序运行的平台时间,即:应用程序结束的时刻-应用程序起始时刻。
buffer_gets:consistent gets 逻辑读
disk_reads:physical reads 物理读
rows_processed: rows processed 结果条数
在v$sql_plan里查看执行计划
SELECT LPAD(' ', 2 * (LEVEL - 1)) || OPERATION || ' ' ||
DECODE(ID, 0, 'Cost = ' || POSITION) "OPERATION",
OPTIONS,
OBJECT_NAME,
COST,
CARDINALITY,
CPU_COST,
IO_COST,bytes/1024/1024 as "MB"
FROM V$SQL_PLAN
START WITH ( sql_id='4pn7guqhvxjbn'
AND ID = 0 and child_number=0)
CONNECT BY PRIOR ID = PARENT_ID
AND PRIOR ADDRESS = ADDRESS
AND PRIOR HASH_VALUE = HASH_VALUE
AND PRIOR CHILD_NUMBER = CHILD_NUMBER 得出实际的执行计划。