Unix Technical Forum

Interesting SQL that displays time taken to do row count?

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 ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-24-2008, 04:45 PM
Snewber
 
Posts: n/a
Default Interesting SQL that displays time taken to do row count?

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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-24-2008, 04:45 PM
sybrandb@yahoo.com
 
Posts: n/a
Default Re: Interesting SQL that displays time taken to do row count?

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-24-2008, 05:02 PM
Sybrand Bakker
 
Posts: n/a
Default Re: Interesting SQL that displays time taken to do row count?

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:37 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com