Vous êtes sur la page 1sur 1

Tip One of the most common reasons for a sub-optimal explain plan is the lack of current statistics on one

or more objects involved in a query. With a simple query against the V$SESSION_LONGOPS view, you can quickly get an i dea of how long the query will execute, and when it will finish: V$SESSION_LONGOPS SELECT username, target, sofar blocks_read, totalwork total_blocks, round(time_remaining/60) minutes FROM v$session_longops WHERE sofar <> totalwork and username = 'HR'; USERNAME TARGET BLOCKS_READ TOTAL_BLOCKS MINUTES ------------ -------------------- ----------- ------------ ---------HR HR.EMPLOYEES_BIG 81101 2353488 10 The query must run for six seconds or greater. The table being accessed must be greater than 10,000 database blocks. TIMED_STATISTICS must be set or SQL_TRACE must be turned on. The objects within the query must have been analyzed via DBMS_STATS or ANALYZE.

V$SESSION_LONGOPS view include table scans, index scans, join operations, parall el operations, RMAN backup operations, sort operations, and Data Pump operations. Look at the V$SQLSTATS view, which gives information about currently or recently run SQL statements. If you wanted to get the top five recent SQL statements that performed the highest disk I/O, you could issue the following query: SELECT sql_text, disk_reads FROM (SELECT sql_text, buffer_gets, disk_reads, sorts, cpu_time/1000000 cpu, rows_processed, elapsed_time FROM v$sqlstats ORDER BY disk_reads DESC) WHERE rownum <= 5;

Vous aimerez peut-être aussi