Oracle Logbook

October 21, 2011

Simple way to get CPU usage

Filed under: Uncategorized — heliodias @ 6:36 pm

Often we want just the CPU usage from a query rather than complete 10046,

As Tom Kyte published in setember Oracle Magazine:

SQL> begin
   2   :cpu := dbms_utility.get_cpu_time;
   3   dbms_application_info.set_client_info(0);
   4 end;
   5 /
PL/SQL procedure successfully completed.

SQL> select owner, f(owner) from stage;

72841 rows selected.

SQL> select
  2  dbms_utility.get_cpu_time-:cpu cpu_hsecs,
  3  userenv(‘client_info’)
  4  from dual;

CPU_HSECS   USERENV(‘CLIENT_INFO’)
———   ———————–
       118                     72841

To read the whole article:

http://www.oracle.com/technetwork/issue-archive/2011/11-sep/o51asktom-453438.html

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: