Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Does the elapsed_time column in the v$sql table indicate the time per query exeuction or is it a sum of all executions?

share|improve this question
2  
that should be pretty easy to test, shouldn't it? –  Jack Douglas Sep 2 '11 at 11:23
    
@Jack: right, but it's even easier to ask on dba.stackexchange.com –  René Nyffenegger Sep 2 '11 at 12:49
add comment

1 Answer

up vote 4 down vote accepted

From the 11.2 Database Reference documentation:

Elapsed time (in microseconds) used by this cursor for parsing, executing, and fetching

Here is a demonstration:

SQL> SELECT sql_text, elapsed_time FROM v$sql WHERE sql_text like '%lewap %';

SQL_TEXT
-----------------------------------------------------------------------------
ELAPSED_TIME
------------
SELECT sql_text, elapsed_time FROM v$sql WHERE sql_text like '%lewap %'
        5112


SQL> SELECT sql_text, elapsed_time FROM v$sql WHERE sql_text like '%lewap %';

SQL_TEXT
-----------------------------------------------------------------------------
ELAPSED_TIME
------------
SELECT sql_text, elapsed_time FROM v$sql WHERE sql_text like '%lewap %'
       26332


SQL> SELECT sql_text, elapsed_time FROM v$sql WHERE sql_text like '%lewap %';

SQL_TEXT
-----------------------------------------------------------------------------
ELAPSED_TIME
------------
SELECT sql_text, elapsed_time FROM v$sql WHERE sql_text like '%lewap %'
       65886


SQL> SELECT sql_text, elapsed_time FROM v$sql WHERE sql_text like '%lewap %';

SQL_TEXT
-----------------------------------------------------------------------------
ELAPSED_TIME
------------
SELECT sql_text, elapsed_time FROM v$sql WHERE sql_text like '%lewap %'
      103225

If you need the timing for one execution you could set timing on in an SQL*Plus session, turn on tracing with TIMED_STATISTICS, or add a comment to the SQL so that there is only one execution in v$sql.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.