This is a discussion on Interesting SQL that displays time taken to do row count? within the Oracle Database forums, part of the Database Server Software category; --> I can't get the correct value for t2 - t1 for the following query. Maybe adding t2 - t1 ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I can't get the correct value for t2 - t1 for the following query. Maybe adding t2 - t1 changes the execution plan and thus you get incorrect results? In that case what hints or changes are needed to fix it? select (dbms_utility.get_time ) t1, (select count(*) from dba_source) row_count, (dbms_utility.get_time) t2 from dual; The following query seems to return the correct SECONDS_TO_EXECUTE, but not for the first column, DOES_NOT_WORK. When I remove the column, DOES_NOT_WORK, it makes the SECONDS_TO_EXECUTE column incorrect. select hsecs - t1 DOES_NOT_WORK, row_count, round((t2 - t1)/100,5) SECONDS_TO_EXECUTE from ( select (select * from V$TIMER) t1, (select count(*) from dba_source) row_count, (select * from V$TIMER) t2 from dual ), v$timer; Does anyone know how to improve the above query, or write a new query in one SQL statement, so that you can get the following: ROW_COUNT SECONDS_TO_EXECUTE --------- ------------------ 99999 1.99 If you run the above query from SQLPlus with timing on, and timing on said 2.2 seconds, would that mean the difference , 2.22 - 1.99, was due to how long it took to send and receive the data? |
| |||
| Basically you can't. You are on the wrong track. Also you seem to be tracking information that is already being maintained in v$sql. But if you insist: you really need to get_time run query get_time and/or generate level 12 trace files or better still, buy something like Quest Central and don't waste your time on reinventing the wheel. -- Sybrand Bakker Senior Oracle DBA |
| ||||
| On Fri, 30 Sep 2005 16:36:30 +1000, Snewber <snew@snew.com> wrote: >Does anyone know how to improve the above query, or write a new query in >one SQL statement, so that you can get the followin You should stop wasting your time on getting out any results which are already maintained in the v$ tables, and can be produced by tracing a session. You would better try to learn how Oracle works. -- Sybrand Bakker, Senior Oracle DBA |