PL/Sql sleep for a few microseconds
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 7 of 7

Thread: PL/Sql sleep for a few microseconds

  1. #1
    Join Date
    Feb 2007
    Posts
    3

    PL/Sql sleep for a few microseconds

    I would like to code a pl/sql for loop which stresses my cpu approximately 5%.

    Without sleep the cpu is fully stressed 100%.
    So my sleep in the loop should be very small.

    I only know these two Packages.

    execute dbms_lock.sleep(0.05);
    execute user_lock.sleep(5);

    But their precision is 1/100 second so it doesn't fit my needs.

    Does anyone know a alternative with a precision around microseconds?

  2. #2
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,135
    SQL> begin
    2 dbms_lock.sleep(1/10000) ;
    3 end;
    4 /

    PL/SQL procedure successfully completed.


    Tamil
    www.oracleact.com

  3. #3
    Join Date
    Feb 2007
    Posts
    3
    The problem is oracle cuts off all number after a precision of 1/100 so it doesn't matter what i enter.

    ex. dbms_lock.sleep(0.0001) = dbms_lock.sleep(1/1000) = dbms_lock.sleep(0)

    No errors are shown.

  4. #4
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,135
    A dummy loop will help:

    Code:
    SQL> declare
      2  J NUMBER;
      3  begin
      4     FOR J in 1..100 LOOP
      5       NULL;
      6     END LOOP;
      7  end;
      8  /
    
    PL/SQL procedure successfully completed.

    Tamil
    www.oracleact.com

  5. #5
    Join Date
    Feb 2007
    Posts
    3
    Yes that's true.
    A loop in a loop until my 1/100 seconds are enough for a cpu load of 5%.


    Thank you.

  6. #6
    Join Date
    Apr 2002
    Location
    Phoenix, AZ
    Posts
    175
    You should remember that PL/SQL is designed mainly to code business functionality.

    You can't do to many tricky things with pl/sql. You can try Java instead.
    Sridhar R Patnam

  7. #7
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    Wouldn't the dummy loop cause a delay only by using CPU cycles? I don't see it helping achieve the goal.
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

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