Showing posts with label host. Show all posts
Showing posts with label host. Show all posts

Thursday, September 06, 2012

DB time from V$SESSTAT

This was tested on Oracle 11.2. The DB time entry in V$MYSTAT (or V$SESSTAT) just seems to record the amount of time a session spends doing something in the database, irrespective of the amount of CPU time used. First reconnect to the database to zeroise the figures:

SQL> conn /
Connected.
SQL> select name, m.value/100
  2  from v$mystat m, v$sysstat s
  3  where m.statistic# = s.statistic#
  4  and name in
  5  ('DB time',
  6   'CPU used by this session')
  7  /

NAME                                M.VALUE/100
----------------------------------- -----------
CPU used by this session                    .01
DB time                                       0

SQL>

If you sleep in the OS for a few seconds:

SQL> host sleep 5

... this does not increment DB time or CPU time by much:

SQL> select name, m.value/100
  2  from v$mystat m, v$sysstat s
  3  where m.statistic# = s.statistic#
  4  and name in
  5  ('DB time',
  6   'CPU used by this session')
  7  /

NAME                                M.VALUE/100
----------------------------------- -----------
CPU used by this session                    .02
DB time                                     .02

SQL>

However, if you sleep in the database:

SQL> exec dbms_lock.sleep(5);

PL/SQL procedure successfully completed.

SQL>

... CPU time hardly changes but DB time goes up by the full 5 seconds:

SQL> select name, m.value/100
  2  from v$mystat m, v$sysstat s
  3  where m.statistic# = s.statistic#
  4  and name in
  5  ('DB time',
  6   'CPU used by this session')
  7  /

NAME                                M.VALUE/100
----------------------------------- -----------
CPU used by this session                    .04
DB time                                    5.05

SQL>

Thursday, February 16, 2012

SQL*Plus host Command

The SQL*Plus host command allows you to run operating system commands from within a SQL*Plus session:

SQL> host date
Wed Feb  8 10:56:34 GMT 2012

SQL>

Alternatively, you can use an exclamation mark:

SQL> ! echo "Andrew was here"
Andrew was here

SQL>

... and, if you do, it is not necessary to leave a space between the exclamation mark and the OS command:

SQL> !pwd
/home/oracle/examples/host

SQL>