DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: help with next_time for dbms_job

  1. #1
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166

    Question help with next_time for dbms_job

    We are running Oracle 9.2.0.7 on Windows 2000 Advanced Server.

    We have a job that runs in DBMS_JOB. It looks at v$sql and takes a snapshot every so often and logs this snapshot to a table where presumably someone can go and look at it. The formula used to compute the next run time is sysdate+.05/(24*60). Which I take to mean run every 30 seconds. Is this really every 30 seconds?

    There are times when it takes more than 60 seconds to run. I like the data that I get, but I was thinking about having it run every hour instead of twice per minute.

    Here is the query:

    Code:
    SELECT first_load_time,          NVL(last_load_time,'NA'),
          (elapsed_time * .000001),  sql_text,
           rows_processed,           optimizer_cost,
           cpu_time,                 buffer_gets,
           disk_reads,               MODULE,
           parsing_user_id,          parsing_schema_id
     FROM v$sql
    WHERE to_date(first_load_time,'YYYY-MM-DD/HH24:MI:SS') >  SYSDATE -.5/(24*60)
      AND ROWNUM < 100
    ORDER BY first_load_time desc;
    I want to rewrite it as:

    Code:
    SELECT first_load_time,          NVL(last_load_time,'NA'),
          (elapsed_time * .000001)   elapsed_time,
           sql_text,
           rows_processed,           optimizer_cost,
           cpu_time,                 buffer_gets,
           disk_reads,               MODULE,
           parsing_user_id,          parsing_schema_id
     FROM v$sql
    WHERE to_date(first_load_time,'YYYY-MM-DD/HH24:MI:SS') >  SYSDATE - 1/(24*60)
      AND elapsed_time > 10;
    Any thoughts on the query as well?

    Thanks in advance.

  2. #2
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Quote Originally Posted by gandolf989
    ... sysdate+.05/(24*60). Is this really every 30 seconds?
    No, that's every 3 seconds.

    Any thoughts on the query as well?
    Well, for the first query - using "WHERE ROWNUM < x ORDER BY y" usually means the query will not return quite the same result as the author was hoping for....

    In the second query, the expression
    Code:
    WHERE to_date(first_load_time,'YYYY-MM-DD/HH24:MI:SS') >
          SYSDATE - 1/(24*60)
    means you'll get only the cursors that were loaded in the last minute - weren't the cursors from the last hour that you are interested in?

    In any case, querying V$SQL on a bussy system every 30 seconds realy sounds problematic (to put it mildly)...
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width