How to get execution time for a view inside procedure ?

Hi,
I want execution time for all the views in my database. I tried "execute immediate" but it does not seem to work.
It is not waiting to complete the execution of view to go to next step.
If I am executing the same statement in sqlplus, it is displaying correct time.
Here is my code:
Begin
output_file := UTL_FILE.FOpen ('RECORDING',v_FileName, 'W', 32767);
Open viewcur;
Loop
Fetch viewcur into v_view_name;
     Exit when viewcur%notfound;
     SELECT to_char(systimestamp,'DD-MON-YYYY HH24:MI:SS.FF') into v_start_time from dual;
     v_stmt := 'Select * from ' ||v_view_name ;
     Execute Immediate v_stmt;
SELECT to_char(systimestamp,'DD-MON-YYYY HH24:MI:SS.FF') into v_end_time from dual;
v_record_str := v_start_time||','||v_view_name||','||v_end_time;
     UTL_FILE.PUT_LINE(output_file, v_record_str);
End Loop;
Close viewcur;
utl_file.fClose(output_file);
End ;
Oracle version: 11.1.0.6.0

Hi,
Running with a user with dba privileges:
DECLARE
    CURSOR viewcur IS
        SELECT table_name
        FROM   dictionary d
        WHERE  d.table_name LIKE 'ALL_A%';
    output_file UTL_FILE.file_type;
    v_FileName  VARCHAR2(30) := 'TEST_VIEW_TIME.TXT';
    v_view_name dictionary.table_name%TYPE;
    v_start_time varchar2(30);
    v_end_time varchar2(30);
    v_record_str varchar2(200);
    v_stmt varchar2(200);
BEGIN
    output_file := UTL_FILE.FOpen('EXT_FILES', v_FileName, 'W', 32767);
    OPEN viewcur;
    LOOP
        FETCH viewcur
            INTO v_view_name;
        EXIT WHEN viewcur%NOTFOUND;
        SELECT TO_CHAR(systimestamp, 'DD-MON-YYYY HH24:MI:SS.FF')
        INTO   v_start_time
        FROM   dual;
        v_stmt := 'Select * from ' || v_view_name;
        EXECUTE IMMEDIATE v_stmt;
        SELECT TO_CHAR(systimestamp, 'DD-MON-YYYY HH24:MI:SS.FF')
        INTO   v_end_time
        FROM   dual;
        v_record_str := v_start_time || ',' || v_view_name || ',' || v_end_time;
        UTL_FILE.PUT_LINE(output_file, v_record_str);
    END LOOP;
    CLOSE viewcur;
    utl_file.fClose(output_file);
END;
/TEST_VIEW_TIME.TXT:
02-JUL-2009 11:48:47.953000,ALL_ARGUMENTS,02-JUL-2009 11:48:47.953000
02-JUL-2009 11:48:47.953000,ALL_ALL_TABLES,02-JUL-2009 11:48:47.953000
02-JUL-2009 11:48:47.953000,ALL_ASSOCIATIONS,02-JUL-2009 11:48:47.953000
02-JUL-2009 11:48:47.953000,ALL_AUDIT_POLICIES,02-JUL-2009 11:48:47.999000
02-JUL-2009 11:48:47.999000,ALL_AUDIT_POLICY_COLUMNS,02-JUL-2009 11:48:48.093000
02-JUL-2009 11:48:48.093000,ALL_AWS,02-JUL-2009 11:48:48.187000
02-JUL-2009 11:48:48.187000,ALL_AW_PS,02-JUL-2009 11:48:48.187000
02-JUL-2009 11:48:48.187000,ALL_APPLY,02-JUL-2009 11:48:48.343000
02-JUL-2009 11:48:48.343000,ALL_APPLY_PARAMETERS,02-JUL-2009 11:48:48.421000
02-JUL-2009 11:48:48.421000,ALL_APPLY_KEY_COLUMNS,02-JUL-2009 11:48:48.437000
02-JUL-2009 11:48:48.437000,ALL_APPLY_CONFLICT_COLUMNS,02-JUL-2009 11:48:48.781000
02-JUL-2009 11:48:48.781000,ALL_APPLY_TABLE_COLUMNS,02-JUL-2009 11:48:48.828000
02-JUL-2009 11:48:48.828000,ALL_APPLY_DML_HANDLERS,02-JUL-2009 11:48:48.890000
02-JUL-2009 11:48:48.890000,ALL_APPLY_PROGRESS,02-JUL-2009 11:48:48.968000
02-JUL-2009 11:48:48.968000,ALL_APPLY_ERROR,02-JUL-2009 11:48:49.015000
02-JUL-2009 11:48:49.015000,ALL_APPLY_ENQUEUE,02-JUL-2009 11:48:49.234000
02-JUL-2009 11:48:49.234000,ALL_APPLY_EXECUTE,02-JUL-2009 11:48:49.281000
02-JUL-2009 11:48:49.281000,ALL_AW_PROP,02-JUL-2009 11:48:49.531000
02-JUL-2009 11:48:49.546000,ALL_AW_OBJ,02-JUL-2009 11:48:49.578000
02-JUL-2009 11:48:49.578000,ALL_AW_PROP_NAME,02-JUL-2009 11:48:49.609000
02-JUL-2009 11:48:49.609000,ALL_AW_AC,02-JUL-2009 11:48:49.624000
02-JUL-2009 11:48:49.624000,ALL_AW_AC_10G,02-JUL-2009 11:48:49.640000Regards,

Similar Messages

  • How to get the time for executing an SQL statement?

    hi all...
    How can I get the total execution time for a given SQL statement to a ViewObject which is created dynamically for this SQL so that the end user knows it before hand and try to stop it or go further..?
    Please post any ideas if you have got..!!!
    thanx in advance..
    grüss
    K°vi

    This is not really a question for the JDeveloper forum, but rather for the DB forum.
    Since Oracle9i there is a way to estimate how long a query will take, before executing it.
    Check it out in the Oracle DB documentation or ask on the DB forum.
    There is no built-in functionality for this in JDeveloper, but you should be able to call out to the DB from your Java code to get the estimate.

  • How to get remaining time for baton after setting timeOut property

    Hello,
    Is it possible to get the remaining time for baton after setting timeOut, or do I have to maintain a separate Timer for that?
    Been following this excellent tutorial here http://tv.adobe.com/watch/adc-presents/create-shared-forms-in-livecycle-collaboration-serv ice/

    Thanks Nigel, before reading your reply, I came up with something like this, but it seems extending the Baton class is not enough, as I would need my own BatonProperty as well that uses this extended Baton class...
    Also attempted to get some help here http://stackoverflow.com/questions/7116814/actionscript3-lccs-how-to-access-property-paren t-class-protected-var/7116882#7116882
    Could this be made into a feature request for Baton and BatonProperty, se we could easily get the remaining time please?   I guess I can wait for a future release.
    /custom as file /
    package com.mysite.BatonExtender
         import com.adobe.rtc.sharedModel.Baton;
         import flash.events.TimerEvent;
         public class BatonExtender extends Baton
              public function BatonExtender()
              super();
              _autoPutDownTimer.addEventListener(TimerEvent.TIMER,countDown);    
              trace("CURRENT TIMER:"+_autoPutDownTimer.currentCount);
              trace("BATONEXTENDER added");
              public function countDown(p_evt:TimerEvent):void {
                   trace("TRACING START countDown....");
                   if (_autoPutDownTimer.running) {
                        trace(_autoPutDownTimer.currentCount);
                        //sharedTimer.value = String(90 - _autoPutDownTimer.currentCount);
                   trace("TRACING END....");

  • How to get execution object for ActiveX/CO​M method Step.GetRu​nModeEx?

    I would like to know how to get the execution object to pass into the ActiveX/COM method Step.GetRunModeEx.

    Hey Snood1,
    There are other posts about this out there but as far as information in the released documentation it is kinda vague as to the fact that you can simply put any data type there.  The definition states "Data type that can hold any defined type of data"  But I can see the confusion that you don't have to actually convert it to a variant first.  Generally you do have to convert it first.  However some TestStand functions will allow any datatype and convert it for you. 
    Jon is going to create a Knowledge Base regarding this information and hopefully alleviate some of the pain for others in the future.
    Regards,
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

  • How to optimize execution time for code

    Please suggest the way as i m new to performance tuning for reducing the execution time of code . Related document to performance tuning is appreciable .also tell how to work with Tcode ST05 .
    Thanks in advance

    Please Read before Posting in the Performance and Tuning Forum
    Thread locked.
    Thomas

  • Execution time for web reports

    Hello every one,
    How to calculate execution time for web reports, for query execution we will go through RSRT, by giving query name and press execute + Debug button then select statistical data & Do not Cache buttons then press enter, after getting output press on back button, we will get duration of the query.....
    But my question is , can we calculate execution time for webreport, if so can you please guide me.
    and can you also tell me , if there is any RRI for one report, how to calculate execution time for these queries.
    Ex : Query ABC have XYZ as its drilldown report , i need to calculate execution time for XYZ report via ABC report.
    Thanks in advance,
    Best Regards.
    NP.

    Hi,
    For reports executed in java web you can add the parameter &PROFILING=X
    to the URL in order to record the execution time. Please have a look at SAP note 1048691 for further information.
    Best regards,
    Janine

  • How can i calculate execution time for methods?

    I'm making a project that i want to calculate execution time for a
    method in "miliseconds" or "microseconds".You see,I have a sort algorithm and i want to calculate execution time of this algorithm.How can i do?
    Thanks...

    Just remembered.
    The answer you get isn't trustworthy below a hundred millis, so you may need to sort a hundred or a thousand times to get a reasonable elapsed time. You also need to run the test five or ten times and take an average. In Windows you should fire up the Task Manager and be sure that your other CPU usage is as near to zero as you can get.

  • How to get column names for a specific view in the scheme?

    how to get column names for a specific view in the scheme?
    TIA
    Don't have DD on the wall anymore....

    or this?
    SQL> select text from ALL_VIEWS
      2  where VIEW_NAME
      3  ='EMP_VIEW';
    TEXT
    SELECT empno,ename FROM EMP
    WHERE empno=10

  • How to get wage type for every time record

    Hi Pros,
          I am using DS 0CA_TS_IS_1, it includes report time type (0REPTT), but not have wage type. in CATSDB, I fied fields for attendance/absence type and wage type. but not every time record has wage type. can you please tell me how to get wage type for every time record? what is relation between reporting time type, attendance/absence type and wage typs?

    Hello,
    Can you talk to your HR/T&E functional consultant if they populate these values in CATSDB table using standard way or if there are custom fields that are in CATSDB OR any other table which can be used to meed the requirements
    Thanks
    Abhishek Shanbhigue

  • How to find the Execution Time for Java Code?

    * Hi everyone , i want to calculate the execution time for my process in java
    * The following was the ouput for my coding,
    O/P:-
    This run took 0 Hours ;1.31 Minutes ;78.36 Seconds
    *** In the above output , the output should come exactly what hours , minutes and seconds for my process,
    but in my code the minutes are converted into seconds(It should not)...
    * Here is my coding,
        static long start_time;
        public static void startTime()
            start_time = System.currentTimeMillis();
        public static void endTime()
            DecimalFormat df = new DecimalFormat("##.##");
            long end_time = System.currentTimeMillis();
            float t = end_time - start_time;
            float sec = t / 1000;
            float min = 0, hr = 0;
            if (sec > 60) {
                min = sec / 60;
            if (min > 60) {
                hr = min / 60;
            System.out.println("This run took " + df.format(hr) + " Hours ;"+ df.format(min) + " Minutes ;" + df.format(sec) + " Seconds");
        }* How to Calcualte exact timing for my process....
    * Thanks

    * Hi flounder, Is following code will wotk perfectly?
         public static void endTime()
              DecimalFormat df = new DecimalFormat("##.##");
              long end_time = System.currentTimeMillis();
              float t = end_time - start_time;
              float sec = t / 1000;
              float min = 0, hr = 0;
              while(sec >= 60){
         min++;
         sec = sec -60;
         if (min >= 60){
         min = 0; //or min = min -60;
         hr++;
              System.out.println("This run took " + df.format(hr) + " Hours ;"+ df.format(min) + " Minutes ;" + df.format(sec) + " Seconds");
         }

  • How to get the time interveral for each status of worklow (wating,Inprocess

    Hi Friends,
    I have requreiemnt to get the time interval for each status of workflow.
    ex.
                                                                     status
    workflow id  | startd date | enddate       | waiting | Inprocessing|Error|......
    1026            10.10.2008  25.10.2008        1hr      1hr 30 min    2 hr
    Please do give me idea how to get the time stam of each status of workflow.
    Thanks,
    D.prabhu

    Hi,
    I think the following tables would be helpful to you:-
    SWW_CONT     Container Contents for Work Item Data Container
    SWW_CONTOB     "Container Cont. for Work Item Data Container (Only Objects)"     
    SWWLOGHIST     History of a work item     
    SWWORGTASK     Assignment of WIs to Org.Units and Tasks     
    SWWUSERWI      Current Work Items Assigned to a User     
    SWWWIHEAD     Header Table for all Work Item Types
    Hope it Helps!
    Regards,
    Kanika

  • How to find out the execution time of a sql inside a function

    Hi All,
    I am writing one function. There is only one IN parameter. In that parameter, i will pass one SQL select statement. And I want the function to return the exact execution time of that SQL statement.
    CREATE OR REPLACE FUNCTION function_name (p_sql IN VARCHAR2)
    RETURN NUMBER
    IS
    exec_time NUMBER;
    BEGIN
    --Calculate the execution time for the incoming sql statement.
    RETURN exec_time;
    END function_name;
    /

    Please note that wrapping query in a "SELECT COUNT(*) FROM (<query>)" doesn't necessarily reflect the execution time of the stand-alone query because the optimizer is smart and might choose a completely different execution plan for that query.
    A simple test case shows the potential difference of work performed by the database:
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    Session altered.
    SQL>
    SQL> drop table count_test purge;
    Table dropped.
    Elapsed: 00:00:00.17
    SQL>
    SQL> create table count_test as select * from all_objects;
    Table created.
    Elapsed: 00:00:02.56
    SQL>
    SQL> alter table count_test add constraint pk_count_test primary key (object_id)
    Table altered.
    Elapsed: 00:00:00.04
    SQL>
    SQL> exec dbms_stats.gather_table_stats(ownname=>null, tabname=>'COUNT_TEST')
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.29
    SQL>
    SQL> set autotrace traceonly
    SQL>
    SQL> select * from count_test;
    5326 rows selected.
    Elapsed: 00:00:00.10
    Execution Plan
    Plan hash value: 3690877688
    | Id  | Operation         | Name       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |            |  5326 |   431K|    23   (5)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| COUNT_TEST |  5326 |   431K|    23   (5)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
            419  consistent gets
              0  physical reads
              0  redo size
         242637  bytes sent via SQL*Net to client
           4285  bytes received via SQL*Net from client
            357  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
           5326  rows processed
    SQL>
    SQL> select count(*) from (select * from count_test);
    Elapsed: 00:00:00.00
    Execution Plan
    Plan hash value: 572193338
    | Id  | Operation             | Name          | Rows  | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT      |               |     1 |     5   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE       |               |     1 |            |          |
    |   2 |   INDEX FAST FULL SCAN| PK_COUNT_TEST |  5326 |     5   (0)| 00:00:01 |
    Statistics
              1  recursive calls
              0  db block gets
             16  consistent gets
              0  physical reads
              0  redo size
            412  bytes sent via SQL*Net to client
            380  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              1  rows processed
    SQL>As you can see the number of blocks processed (consistent gets) is quite different. You need to actually fetch all records, e.g. using a PL/SQL block on the server to find out how long it takes to process the query, but that's not that easy if you want to have an arbitrary query string as input.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle:
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • Execution Time for T.Code

    Hi Experts,
    I want to know the exact execution time for a t.code. I check it in ST03 or ST03n but I can't get proper data. In ST03 I get the average and total response time but I want the exact ececution or response  time.
    Waiting for your inputs.
    Regards,
    Nisit

    From SAP
    For old verions
    In ST03 transaction
    click on "Performance Database" tab 
    Then double click on Total
    It will open Dialogue box CHOOSE TIME PERIOD  ,select the time period and then click on the required date
    Then Click on Transaction Profile ,here it will give the list of transaction executed and its execution time
    In STO3N , you will find "TRANSACTION PROFILE" under Analysis views, when you double click on it will give present days Transaction codes executed.
    If you want the month data then go to Export mode in ST03n ,you will get the data "TRANSACTION PROFILE" under Analysis views  .
    Regards,
    Beena

  • Can I reduce the execution time for a step in a TestStand ?

    Hi,
    I calculated the a single step execution time for TestStand Ver 2.0. It comes to around 20 milliseconds/step. Can I reduce this excution time ?
    Are there any settings available for configuring execution time parameters except result logging and exception handlings to reduce the execution time ?

    It's difficult to tell how you what time you are reporting for your step. Clearly we don't have control of the time it takes your code to execute. However, we are constantly working on reducing the overhead of calling the code. In addition, you don't mention the type of step you are calling. One way to have a common reference is to use the example \Examples\Benchmarks\Benchmarks.seq. Below have have posted the results of running this sequence with both tracing and result collection enabled and then disabled. I have a 700 MHz, 128 MB RAM, Dell PIII laptop. In this example there is no code within the code modules. You notice that calling a DLL has the least overhead with a minimum of 7.459 ms with tracing and results enabled and 0.092 ms with tracing and results disabled. Although not included below, if I enable results be disable tracing I get a minimum time of 0.201 ms, a 100x improvement on your time.
    With Results and Tracing enabled.
    7.578 milliseconds per step for CVI Standard Prototype - Object File
    7.579 milliseconds per step for CVI Standard Prototype - DLL
    7.459 milliseconds per step for DLL Flexible Prototype
    8.589 milliseconds per step for DLL Flexible Prototype Numeric Limit
    9.563 milliseconds per step for DLL Flexible Prototype Numeric Limit with Precondition
    10.015 milliseconds per step for DLL Flexible Prototype Numeric Limit with Precondition and 4 Parameters
    7.868 milliseconds per step for ActiveX Automation
    8.892 milliseconds per step for LabVIEW Standard Prototype
    With tracing and results disabled.
    0.180 milliseconds per step for CVI Standard Prototype - Object File
    0.182 milliseconds per step for CVI Standard Prototype - DLL
    0.092 milliseconds per step for DLL Flexible Prototype
    0.178 milliseconds per step for DLL Flexible Prototype Numeric Limit
    0.277 milliseconds per step for DLL Flexible Prototype Numeric Limit with Precondition
    0.400 milliseconds per step for DLL Flexible Prototype Numeric Limit with Precondition and 4 Parameters
    0.270 milliseconds per step for ActiveX Automation
    1.235 milliseconds per step for LabVIEW Standard Prototype

  • Estimate execution time for CTAS

    Hi,
    I am searching for long to find a way to estimate the execution time for CTAS commands. I am a DBA. Our users run CTAS commands to load millions of rows. The commands fetch data from 4-5 very big tables each with millions of records and process them using where clause and group by clause and finally create the table. All these things are coded in the CTAS command. These CTAS sometime takes long time like 5 , 8 Hrs. Users frequently ask me to find how long it's going to take. I use both OEM and TOAD. But I couldn't find the time estimated from these tools. I feel that there must be some way, but I don't know the method.
    Can any body please help me in this regard?
    Thanks & Regards
    Ananda Basak

    It depends on a number of factors chief among them how accurate your estimate needs to be but also including things like what version of Oracle you're using, how accurate your database statistics are, etc.
    One option is to look at the TIME column in the plan. For example, if I wanted to do a CTAS to create a copy of the EMP table, the optimizer expects that to take on the order of a second. Of course, the optimizer's estimates are only estimates and are only as accurate as the database statistics that are in place. If the optimizer generates a bad plan, it's likely because the optimizer expects some operation to take much more or much less time than it does in reality in which case the optimizer's runtime estimate is likely to be way off.
    SQL> explain plan for create table emp_copy as select * from emp;
    Explained.
    SQL> ed
    Wrote file afiedt.buf
      1  select *
      2*   from table( dbms_xplan.display() )
    SQL> /
    PLAN_TABLE_OUTPUT
    Plan hash value: 2748781111
    | Id  | Operation              | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | CREATE TABLE STATEMENT |          |    14 |   546 |     4   (0)| 00:00:01 |
    |   1 |  LOAD AS SELECT        | EMP_COPY |       |       |            |          |
    |   2 |   TABLE ACCESS FULL    | EMP      |    14 |   546 |     3   (0)| 00:00:01 |
    -----------------------------------------------------------------------------------Depending on the query plan, you may be able to query the GV$SESSION_LONGOPS table to track the progress of any long-running operations in your session. If your query plan involves a lot of full table scans, sorts that take more than a few seconds, hash joins, etc. then it is likely that you'll be able to chart the progress of a query over time by watching GV$SESSION_LONGOPS change. Of course, if your query is going to need to do many long-running operations, you'll need to a human to interpret the data a bit in order to figure out where in the plan Oracle currently is and how far along that means the entire query is.
    SELECT *
      FROM gv$session_longops
    WHERE time_remaining > 0If you're using 11g and you have the performance and tuning pack licensed, you could also potentially use the V$SQL_PLAN_MONITOR view.
    Justin

Maybe you are looking for

  • [SOLVED]LUKS error while booting

    This is more of an annoyance than a real problem; however it would be nice to know what is causing this. I have an unencrypted root (/dev/sda3) and two encrypted partitions. While booting I get the following message: ERROR:Failed to open encryption m

  • Error while posting data from SCM to XI

    Dear Expertise, I got a requirement where I need to post data from SCM to XI server. From SCM side it is an ABAP proxy. When I tested the scenario and checked in the MONI of SCM I got an error. But SCM is correctly configured pointing to XI under Tco

  • Compile With GTK2 vs GTK3

    A number of programs I use are now using GTK3 (shotwell & remmina for example) and they look like crap on my system.  I know I can install a GTK3 theme to improve the look but I would prefer to use my current GTK2 theme if that is an option.  There i

  • Help on dropdown jTextField

    package ui; import entity.*; import ui.*; import database.*; import controller.*; import javax.swing.JFrame; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPopupMenu; import java.awt.Borde

  • OLAP Universe  Sturcture in Production not same as Dev and QA

    We have created a OLAP Univese from a SAP BEX Query .The BEX Qeury  is identical in structure and Result in Dev(migrated to QA and Production) The BOBJ Olap Universe creates a Main Class ( FROM SAP DIMENSION -Three of them ) and Sub Class ( Character