What is iostat??

iostat is Linux Command basically use for Performance Monitoring.
iostat reports CPU, disk I/O, and NFS statistics.


1. iostat – Basic example

Iostat without any argument displays information about the CPU usage, and I/O statistics about all the partitions on the system as shown below.

$ iostat
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           5.68    0.00    0.52    2.03    0.00   91.76

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda             194.72      1096.66      1598.70 2719068704 3963827344
sda1            178.20       773.45      1329.09 1917686794 3295354888
sda2             16.51       323.19       269.61  801326686  668472456
sdb             371.31       945.97      1073.33 2345452365 2661206408
sdb1            371.31       945.95      1073.33 2345396901 2661206408
sdc             408.03       207.05       972.42  513364213 2411023092
sdc1            408.03       207.03       972.42  513308749 2411023092

2. iostat – Display only cpu statistics

iostat option -c, displays only the CPU usage statistics as shown below.

$ iostat -c
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           5.68    0.00    0.52    2.03    0.00   91.76

3. iostat – Display only disk I/O statistics

iostat option -d, displays only the disk I/O statistics as shown below.

$ iostat -d
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda             194.71      1096.61      1598.63 2719068720 3963827704
sda1            178.20       773.41      1329.03 1917686810 3295355248
sda2             16.51       323.18       269.60  801326686  668472456
sdb             371.29       945.93      1073.28 2345452365 2661209192
sdb1            371.29       945.91      1073.28 2345396901 2661209192
sdc             408.01       207.04       972.38  513364213 2411024484
sdc1            408.01       207.02       972.38  513308749 2411024484

4. iostat – Display only network statistics

iostat option -n, displays only the device and NFS statistics as shown below.
 
$ iostat -n
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)        07/09/2011

avg-cpu:  %user   %nice    %sys %iowait   %idle
           4.33    0.01    1.16    0.31   94.19

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda               2.83         0.35         5.39   29817402  457360056
sda1              3.32        50.18         4.57 4259963994  387641400
sda2              0.20         0.76         0.82   64685128   69718576
sdb               6.59        15.53        42.98 1318931178 3649084113
sdb1             11.80        15.53        42.98 1318713382 3649012985

Device:                  rBlk_nor/s   wBlk_nor/s   rBlk_dir/s   wBlk_dir/s   rBlk_svr/s   wBlk_svr/s
192.168.1.4:/home/data      90.67        0.00         0.00         0.00         5.33         0.00
192.168.1.4:/backup         8.74         0.00         0.00         0.00         8.74         0.00
192.168.1.8:/media          0.02         0.00         0.00         0.00         0.01         0.00

5. iostat – Display I/O data in MB/second

By default iostat, displays the device I/O statistics in Blocks. To change it to MB, use -m as shown below.
 
$ iostat -m
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           5.68    0.00    0.52    2.03    0.00   91.76

Device:            tps    MB_read/s    MB_wrtn/s    MB_read    MB_wrtn
sda             194.70         0.54         0.78    1327670    1935463
sda1            178.19         0.38         0.65     936370    1609060
sda2             16.51         0.16         0.13     391272     326402
sdb             371.27         0.46         0.52    1145240    1299425
sdb1            371.27         0.46         0.52    1145213    1299425
sdc             407.99         0.10         0.47     250666    1177259
sdc1            407.99         0.10         0.47     250639    1177259

6. iostat – Display I/O statistics only for a device

By default iostat displays I/O data for all the disks available in the system. To view statistics for a specific device (For example, /dev/sda), use the option -p as shown below.

$ iostat -p sda
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           5.68    0.00    0.52    2.03    0.00   91.76

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda             194.69      1096.51      1598.48 2719069928 3963829584
sda2            336.38        27.17        54.00   67365064  133905080
sda1            821.89         0.69       243.53    1720833  603892838

7. iostat – Display timestamp information

By default iostat displays only the current date. To display the current time, use the option -t as shown below.
 
$ iostat -t
 
 Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011

Time: 08:57:52 AM
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           5.68    0.00    0.52    2.03    0.00   91.76

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda             194.69      1096.49      1598.45 2719070384 3963829704
sda1            178.18       773.32      1328.88 1917688474 3295357248
sda2             16.51       323.14       269.57  801326686  668472456
sdb             371.25       945.82      1073.16 2345452741 2661228872
sdb1            371.25       945.80      1073.16 2345397277 2661228872
sdc             407.97       207.02       972.27  513364233 2411030200
sdc1            407.97       207.00       972.27  513308769 2411030200

8. iostat – Display Extended status

Use option -x, which will displays extended disk I/O statistics information as shown below.

$ iostat -x
 
 Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           5.68    0.00    0.52    2.03    0.00   91.76

Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
sda              27.86    63.53 61.77 132.91  1096.46  1598.40    13.84     0.21    1.06   2.28  44.45
sda1              0.69    33.22 48.54 129.63   773.30  1328.84    11.80     1.39    7.82   2.28  40.57
sda2             27.16    30.32 13.23  3.28   323.13   269.56    35.90     0.55   32.96   3.44   5.68
sdb              39.15   215.16 202.20 169.04   945.80  1073.13     5.44     1.05    2.78   1.64  60.91
sdb1             39.15   215.16 202.20 169.04   945.77  1073.13     5.44     1.05    2.78   1.64  60.91
sdc               8.90     3.63 356.56 51.40   207.01   972.24     2.89     1.04    2.56   1.55  63.30
sdc1              8.90     3.63 356.55 51.40   206.99   972.24     2.89     1.04    2.56   1.55  63.30

To display extended information for a specific partition (For example, /dev/sda1), do the following.

$ iostat -x sda1
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           5.68    0.00    0.52    2.03    0.00   91.76

Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
sda1              0.69    33.21 48.54 129.62   773.23  1328.76    11.80     1.39    7.82   2.28  40.56

9. iostat – Execute Every x seconds (for y number of times)

To execute iostat every 2 seconds (until you press Ctl-C), do the following.

$ iostat 2
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           5.68    0.00    0.52    2.03    0.00   91.76

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda             194.67      1096.39      1598.33 2719070584 3963891256
sda1            178.16       773.26      1328.79 1917688482 3295418672
sda2             16.51       323.11       269.54  801326878  668472584
sdb             371.22       945.74      1073.08 2345454041 2661251200
sdb1            371.22       945.72      1073.08 2345398577 2661251200
sdc             407.93       207.00       972.19  513366813 2411036564
sdc1            407.93       206.98       972.19  513311349 2411036564
..
To execute every 2 seconds for a total of 3 times, do the following.

$ iostat 2 3

10. iostat – Display LVM statistic (and version)

To display the LVM statistics use option -N as shown below.

$ iostat -N
To display the version of iostat, use -V. This will really display the version information of sysstat, as iostat is part of sysstat package.

$ iostat -V
sysstat version 7.0.2
(C) Sebastien Godard

What is MPSTAT???


This command use for Linux Performance Monitoring purpose.
mpstat is Linux command,Its use for  reports processors statistics.


1. mpstat – Display basic info

By default mpstat displays CPU statistics as shown below.

$ mpstat
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011

10:25:32 PM  CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s
10:25:32 PM  all    5.68    0.00    0.49    2.03    0.01    0.02    0.00   91.77    146.55

2. mpstat – Display all information

Option -A, displays all the information that can be displayed by the mpstat command as shown below. This is really equalivalent to “mpstat -I ALL -u -P ALL” command.

$ mpstat -A
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011      _x86_64_        (4 CPU)

10:26:34 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
10:26:34 PM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00   99.99
10:26:34 PM    0    0.01    0.00    0.01    0.01    0.00    0.00    0.00    0.00   99.98
10:26:34 PM    1    0.00    0.00    0.01    0.00    0.00    0.00    0.00    0.00   99.98
10:26:34 PM    2    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
10:26:34 PM    3    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00

10:26:34 PM  CPU    intr/s
10:26:34 PM  all     36.51
10:26:34 PM    0      0.00
10:26:34 PM    1      0.00
10:26:34 PM    2      0.04
10:26:34 PM    3      0.00

10:26:34 PM  CPU     0/s     1/s     8/s     9/s    12/s    14/s    15/s    16/s    19/s    20/s    21/s    33/s   NMI/s   LOC/s   SPU/s   PMI/s   PND/s   RES/s   CAL/s   TLB/s   TRM/s   THR/s   MCE/s   MCP/s   ERR/s   MIS/s
10:26:34 PM    0    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    7.47    0.00    0.00    0.00    0.00    0.02    0.00    0.00    0.00    0.00    0.00    0.00    0.00
10:26:34 PM    1    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    4.90    0.00    0.00    0.00    0.00    0.03    0.00    0.00    0.00    0.00    0.00    0.00    0.00
10:26:34 PM    2    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.04    0.00    0.00    0.00    0.00    0.00    3.32    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00
10:26:34 PM    3    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    4.17    0.00    0.00    0.00    0.00    0.01    0.00    0.00    0.00    0.00    0.00    0.00    0.00

3. mpstat – Display CPU statistics of individual CPU (or) Core

Option -P ALL, displays all the individual CPUs (or Cores) along with its statistics as shown below.

$ mpstat -P ALL
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011      _x86_64_        (4 CPU)

10:28:04 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
10:28:04 PM  all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00   99.99
10:28:04 PM    0    0.01    0.00    0.01    0.01    0.00    0.00    0.00    0.00   99.98
10:28:04 PM    1    0.00    0.00    0.01    0.00    0.00    0.00    0.00    0.00   99.98
10:28:04 PM    2    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
10:28:04 PM    3    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00

To display statistics information of a particular CPU (or core), use option -P as shown below.

$ mpstat -P 0
Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011      _x86_64_        (8 CPU)

10:28:53 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
10:28:53 PM    0    0.01    0.00    0.01    0.01    0.00    0.00    0.00    0.00   99.98

$ mpstat -P 1 
 Linux 2.6.32-100.28.5.el6.x86_64 (dev-db)       07/09/2011      _x86_64_        (8 CPU)

10:28:55 PM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
10:28:55 PM    1    0.00    0.00    0.01    0.00    0.00    0.00    0.00    0.00   99.98
Finally, as we mentioned earlier mpstat is part of the sysstat package. When you do mpstat -V, it will really display the version number of the systat package as shown below.

$ mpstat -V
sysstat version 9.0.4
(C) Sebastien Godard (sysstat  orange.fr)



what is Vmstate????

 vmstat is Linux command its basic work is display virtual memory statistics.

Its use for Linux Performance Monitoring.

vmstat by default will display the memory usage (including swap) as shown below.

$ vmstat
 
 procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0 305416 260688  29160 2356920    2    2     4     1    0    0  6  1 92  2  0
vmstat output contains the following fields:
  • Procs – r: Total number of processes waiting to run
  • Procs – b: Total number of busy processes
  • Memory – swpd: Used virtual memory
  • Memory – free: Free virtual memory
  • Memory – buff: Memory used as buffers
  • Memory – cache: Memory used as cache.
  • Swap – si: Memory swapped from disk (for every second)
  • Swap – so: Memory swapped to disk (for every second)
  • IO – bi: Blocks in. i.e blocks received from device (for every second)
  • IO – bo: Blocks out. i.e blocks sent to the device (for every second)
  • System – in: Interrupts per second
  • System – cs: Context switches
  • CPU – us, sy, id, wa, st: CPU user time, system time, idle time, wait time

1. vmstat – Display active and inactive memory

By default vmstat doesn’t display this information. Use option -a, to display active and inactive memory information as shown below.
 
$ vmstat -a
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free  inact active   si   so    bi    bo   in   cs us sy id wa st
 0  0 305416 253820 1052680 2688928    2    2     4     1    0    0  6  1 92  2  0

2. vmstat – Display number of forks since last boot

This displays all the fork system calls made by the system since the last boot. This displays all fork, vfork, and clone system call counts.
$ vmstat -f
     81651975 forks

3. vmstat – Execute Every x seconds (for y number of times)

To execute every 2 seconds, do the following. You have to press Ctrl-C to stop this.
$ vmstat 2
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 1  0      0 537144 182736 6789320    0    0     0     0    1    1  0  0 100  0  0 
 0  0      0 537004 182736 6789320    0    0     0     0   50   32  0  0 100  0  0 
..
To execute every 2 seconds for 10 times, do the following. You don’t need to press Ctrl-C in this case. After executing 10 times, it will stop automatically.
$ vmstat 2 10
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 1  0      0 537144 182736 6789320    0    0     0     0    1    1  0  0 100  0  0 
 0  0      0 537004 182736 6789320    0    0     0     0   50   32  0  0 100  0  0 
..

4. vmstat – Display timestamp

When you use vmstat to monitor the memory usage repeately, it would be nice to see the timestap along with every line item. Use option -t to display the time stamp as shown below.
$ vmstat -t 1 100
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------ ---timestamp---
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0 3608728 148368 3898200    0    0     0     0    1    1  0  0 100  0  0     2011-07-09 21:16:28 PDT
 0  0      0 3608728 148368 3898200    0    0     0     0   60   15  0  0 100  0  0     2011-07-09 21:16:29 PDT
 0  0      0 3608712 148368 3898200    0    0     0     0   32   28  0  0 100  0  0     2011-07-09 21:16:30 PDT
For me, the timestamp option worked in the following version.
$ vmstat -V
procps version 3.2.8
Note: If you use a older version of vmstat, option -t might not be available. In that case, use the method we suggested earlier to display timestamp in vmstat output.

5. vmstat – Display slab info

Use option -m, to display the slab info as shown below.
$ vmstat -m
Cache                       Num  Total   Size  Pages
fib6_nodes                    5    113     32    113
ip6_dst_cache                 4     15    256     15
ndisc_cache                   1     15    256     15
RAWv6                         7     10    768      5
UDPv6                         0      0    640      6
tw_sock_TCPv6                 0      0    128     30
...

6. vmstat – Display statistics in a table format

Instead of displays the values in the record format, you can display the output of vmstat in table format using option -s as shown below.
$ vmstat -s
      4149928  total memory
      3864824  used memory
      2606664  active memory
      1098180  inactive memory
       285104  free memory
        19264  buffer memory
      2326692  swap cache
      4192956  total swap
       274872  used swap
      3918084  free swap
   1032454000 non-nice user cpu ticks
        14568 nice user cpu ticks
     89482270 system cpu ticks
  16674327143 idle cpu ticks
    368965706 IO-wait cpu ticks
      1180468 IRQ cpu ticks
..

7. vmstat – Display disk statistics

Use option -d to display the disk statistics as shown below. This displays the reads, writes, and I/O statistics of the disk.
$ vmstat -d
disk- ------------reads------------ ------------writes----------- -----IO------
       total merged sectors      ms  total merged sectors      ms    cur    sec
sda   153189971 69093708 2719150864 737822879 329617713 157559204 3965687592 4068577985      0 1102243
sdb   501426305 97099356 2345472425 731613156 419220973 533565961 2661869460 1825174087      0 1510434
sdc   884213459 22078974 513390701 452540172 127474901 8993357 2411187300 2133226954      0 1569758

8. vmstat – Increase the width of the display

The default output without increasing the width is shown below.
$ vmstat 1 3
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0 3608688 148368 3898204    0    0     0     0    1    1  0  0 100  0  0
 0  0      0 3608804 148368 3898204    0    0     0     0   72   30  0  0 100  0  0
 0  0      0 3608804 148368 3898204    0    0     0     0   60   27  0  0 100  0  0
Use option -w to increase the width of the output columns as shown below. This give better readability.
$ vmstat -w 1 3
procs -------------------memory------------------ ---swap-- -----io---- --system-- -----cpu-------
 r  b       swpd       free       buff      cache   si   so    bi    bo   in   cs  us sy  id wa st
 0  0          0    3608712     148368    3898204    0    0     0     0    1    1   0  0 100  0  0
 0  0          0    3608712     148368    3898204    0    0     0     0   93   23   0  0 100  0  0
 0  0          0    3608696     148368    3898204    0    0     0     0   35   34   0  0 100  0  0

9. vmstat – Display statistics for a partition

To display the disk I/O statistics of a specific disk partition use option -p as shown below.
$ vmstat -p sdb1
sdb1          reads   read sectors  writes    requested writes
           501423248 2345417917  419221612 2661885948

10. vmstat – Display in MB

By default vmstat displays the memory information in kb. To disply in MB, use the option “-S m” as shown below.

$ vmstat -S m
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0    281    288     19   2386    0    0     4     1    0    0  6  1 92  2  0


 

what is explain plan in oracle 11g ????

 What is Explain Plan???

Oracle10g+ auto generates this table now. No need to run the script after Oracle10g.  IF any of the tools complain about this table not being present…have your DBA create a public synonym for it under the SYS account.  Be sure to drop the PLAN_TABLE in your schema.

NOTE:-
It is important to rerun this script when migrating to a newer instance of Oracle. There are always newer columns and you will not be taking advantage of the latest features of Oracle without using the latest PLAN_TABLE. In Oracle11g+, this table is automatically generated during the migration process.

 

EXPLAIN PLAN Usage :-

When an SQL statement is passed to the server the Cost Based Optimizer (CBO) uses database statistics to create an execution plan which it uses to navigate through the data. Once you've highlighted a problem query the first thing you should do is EXPLAIN the statement to check the execution plan that the CBO has created. This will often reveal that the query is not using the relevant indexes, or indexes to support the query are missing. Interpretation of the execution plan is beyond the scope of this article.

 

Plan Table

The explain plan process stores data in the PLAN_TABLE. This table can be located in the current schema or a shared schema and is created using in SQL*Plus as follows.
-- Creating a shared PLAN_TABLE prior to 11g
SQL> CONN sys/password AS SYSDBA
Connected
SQL> @$ORACLE_HOME/rdbms/admin/utlxplan.sql
SQL> GRANT ALL ON sys.plan_table TO public;
SQL> CREATE PUBLIC SYNONYM plan_table FOR sys.plan_table;
In Oracle 11g a shared PLAN_TABLE is created by default, but you can still create a local version of the table using the "utlxplan.sql" script.

AUTOTRACE - The Easy Option?

Switching on the AUTOTRACE parameter in SQL*Plus causes an explain to be performed on every query.
SQL> SET AUTOTRACE ON
SQL> SELECT *
  2  FROM   emp e, dept d
  3  WHERE  e.deptno = d.deptno
  4  AND    e.ename  = 'SMITH';

     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM
---------- ---------- --------- ---------- --------- ---------- ----------
    DEPTNO     DEPTNO DNAME          LOC
---------- ---------- -------------- -------------
      7369 SMITH      CLERK           7902 17-DEC-80        800
        20         20 RESEARCH       DALLAS



Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT Optimizer=CHOOSE
   1    0   NESTED LOOPS
   2    1     TABLE ACCESS (FULL) OF 'EMP'
   3    1     TABLE ACCESS (BY INDEX ROWID) OF 'DEPT'
   4    3       INDEX (UNIQUE SCAN) OF 'PK_DEPT' (UNIQUE)




Statistics
----------------------------------------------------------
         81  recursive calls
          4  db block gets
         27  consistent gets
          0  physical reads
          0  redo size
        941  bytes sent via SQL*Net to client
        425  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed

SQL>
This is a relatively easy way to get the execution plan but there is an issue. In order to get the execution plan the statement must be run to completion. If the query is particularly inefficient and/or returns many rows, this may take a considerable time. At first glance, using the TRACEONLY option of AUTOTRACE seems to remove this issue, but this option merely suppresses the output of the query data, it doesn't prevent the statement being run. As such, long running queries will still take a long time to complete, but they will not present their data. The following example show this in practice.
CREATE OR REPLACE FUNCTION pause_for_secs(p_seconds IN NUMBER) RETURN NUMBER A
BEGIN
  DBMS_LOCK.sleep(p_seconds);
  RETURN p_seconds;
END;
/

Function created.

SQL> SET TIMING ON
SQL> SET AUTOTRACE ON
SQL> SELECT pause_for_secs(10) FROM DUAL;

PAUSE_FOR_SECS(10)
------------------
                10

1 row selected.

Elapsed: 00:00:10.28

Execution Plan
----------------------------------------------------------
Plan hash value: 1550022268

-------------------------------------------------------------------------
| Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------
|   0 | SELECT STATEMENT |      |     1 |       |     2   (0)| 00:00:01 |
|   1 |  FAST DUAL       |      |     1 |       |     2   (0)| 00:00:01 |
-------------------------------------------------------------------------


Statistics
----------------------------------------------------------
        189  recursive calls
          0  db block gets
        102  consistent gets
          0  physical reads
          0  redo size
        331  bytes sent via SQL*Net to client
        332  bytes received via SQL*Net from client
          4  SQL*Net roundtrips to/from client
         13  sorts (memory)
          0  sorts (disk)
          1  rows processed

SQL> SET AUTOTRACE TRACEONLY
SQL> SELECT pause_for_secs(10) FROM DUAL;

1 row selected.

Elapsed: 00:00:10.26

Execution Plan
----------------------------------------------------------
Plan hash value: 1550022268

-------------------------------------------------------------------------
| Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------
|   0 | SELECT STATEMENT |      |     1 |       |     2   (0)| 00:00:01 |
|   1 |  FAST DUAL       |      |     1 |       |     2   (0)| 00:00:01 |
-------------------------------------------------------------------------


Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
          0  consistent gets
          0  physical reads
          0  redo size
        331  bytes sent via SQL*Net to client
        332  bytes received via SQL*Net from client
          4  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed

SQL>
The query takes the same time to return (about 10 seconds) whether the TRACEONLY option is used or not. If the TRACEONLY option prevented the query running, you would expect it to return instantly, like an EXPLAIN PLAN.
The solution to this is to use the TRACEONLY EXPLAIN option, which only performs the EXPLAIN PLAN, rather than running the statement.

EXPLAIN PLAN

The EXPLAIN PLAN method doesn't require the query to be run, greatly reducing the time it takes to get an execution plan for long-running queries compared to AUTOTRACE. First the query must be explained.
SQL> EXPLAIN PLAN FOR
  2  SELECT *
  3  FROM   emp e, dept d
  4  WHERE  e.deptno = d.deptno
  5  AND    e.ename  = 'SMITH';

Explained.

SQL>
Then the execution plan displayed.
SQL> @$ORACLE_HOME/rdbms/admin/utlxpls.sql

Plan Table
--------------------------------------------------------------------------------
| Operation                 |  Name    |  Rows | Bytes|  Cost  | Pstart| Pstop |
--------------------------------------------------------------------------------
| SELECT STATEMENT          |          |       |      |        |       |       |
|  NESTED LOOPS             |          |       |      |        |       |       |
|   TABLE ACCESS FULL       |EMP       |       |      |        |       |       |
|   TABLE ACCESS BY INDEX RO|DEPT      |       |      |        |       |       |
|    INDEX UNIQUE SCAN      |PK_DEPT   |       |      |        |       |       |
--------------------------------------------------------------------------------

8 rows selected.

SQL>
For parallel queries use the "utlxplp.sql" script instead of "utlxpls.sql".
From Oracle 9i onward, you should display execution plans using the DBMS_XPLAN package.

Statement ID

If multiple people are accessing the same plan table, or you would like to keep a history of the execution plans you should use the STATEMENT_ID. This associates a user specified ID with each plan which can be used when retrieving the data.
SQL> EXPLAIN PLAN SET STATEMENT_ID = 'TIM' FOR
  2  SELECT *
  3  FROM   emp e, dept d
  4  WHERE  e.deptno = d.deptno
  5  AND    e.ename  = 'SMITH';

Explained.

SQL> @explain.sql TIM

PLAN                                   OBJECT_NAME     OBJECT_TYPE     BYTES  COST PARTITION_START PARTITION_STOP
-------------------------------------- --------------- --------------- ----- ----- --------------- ---------------
Select Statement                                                          57     4
  1.1 Nested Loops                                                        57     4
    2.1 Table Access (Full)            EMP             TABLE              37     3
    2.2 Table Access (By Index Rowid)  DEPT            TABLE              20     1
      3.1 Index (Unique Scan)          PK_DEPT         INDEX (UNIQUE)            0

5 rows selected.

SQL>
By default the Oracle scripts do not accept a statement_id parameter. You can easily modify the scripts or you can use the script listed under DBA Scripts on this site.

 

Reading Execution Plans

Execution plans can look very confusing, but reading them is reasonably simple provided you follow three simple rules:
  1. The first operation, or starting point, is the first leaf node, when reading from the top to the bottom. That is, the first element without an indented entry below it. You read from that point backwards.
  2. Join operations always require two sets. The order you read the sets is top down, so the first set is the driving set and the second is the probed set. In the case of a nested loop, the first set is the outer loop. In the case of a hash join, the first set is used to build the hash table.
  3. One join is performed at a time, so you only need to consider two sets and their join operation at any one time.


What is Oracle Workflow Manager in oracle apps R12

Oracle Workflow Manager

Oracle Workflow Manager is a component of Oracle Applications Manager that allows system administrators to manage Oracle Workflow for multiple Oracle E-Business Suite instances from a single console.
Using Oracle Workflow Manager, administrators can control Workflow system services, such as notification mailers, agent listeners, and other service components, background engines, purging obsolete Workflow data, and cleanup of the Workflow control queue. Administrators can also monitor work item processing by viewing the distribution of all work items by status and drilling down to additional information. Additionally, they can monitor event message processing for local Business Event System agents by viewing the distribution of event messages by status as well as queue propagation schedules. With this ability to monitor work items and event messages, a system administrator can identify possible bottlenecks easily.
To access Oracle Workflow Manager, log into Oracle Applications Manager and select an applications system. Then, you can follow one of the following navigation paths:
  • Choose Workflow Manager from the pull-down menu in the Applications Dashboard page and click the Go button.
  • Choose Site Map, choose the Administration tab, and then choose the Home link in the Workflow region of the Site Map page. You can also choose one of the other links in the Workflow region to navigate directly to the corresponding page within Oracle Workflow Manager.
Navigation: Applications Dashboard > (pull-down menu) Workflow Manager > (B) Go
You can also use other features to help manage Oracle Workflow.
  • Use Oracle Diagnostics Framework to run diagnostic tests that check the setup of your Oracle Workflow installation and review debugging information.
  • Use Oracle E-Business Suite Logging to review Oracle Workflow logs. Oracle Workflow uses the Oracle E-Business Suite Logging framework to standardize and centralize in the database logging activities related to the Oracle Workflow Business Event System and Oracle XML Gateway.
    Note: The Java middle tier components of Oracle Workflow, including notification mailers and agent listeners, also use Oracle E-Business Suite Logging; however, due to the high volume of messages that pass through these components, their information is logged to the file system by default.

    Oracle workflow notification mailer related some scripts.


    **************************************************


    1. Workflow: version
     
  •  $FND_TOP/sql/wfver.sql

    **************************************************
    2. check workflow status.
    set linesize 120
    set pagesize 50
    column COMPONENT_NAME format a45
    column STARTUP_MODE format a15
    column COMPONENT_STATUS format a15
    select fsc.COMPONENT_NAME,fsc.STARTUP_MODE,fsc.COMPONENT_STATUS,fcq.last_update_date
    from APPS.FND_CONCURRENT_QUEUES_VL fcq, fnd_svc_components fsc
    where fsc.concurrent_queue_id = fcq.concurrent_queue_id(+)
    order by COMPONENT_STATUS , STARTUP_MODE , COMPONENT_NAME;



    **************************************************
    3. check if workflow is used by only one instance
    col value format a20
    select p.parameter_id,
    p.parameter_name,
    v.parameter_value value
    from apps.fnd_svc_comp_param_vals_v v,
    apps.fnd_svc_comp_params_b p,
    apps.fnd_svc_components c
    where c.component_type = 'WF_MAILER'
    and v.component_id = c.component_id
    and v.parameter_id = p.parameter_id
    and p.parameter_name in ( 'INBOUND_SERVER','ACCOUNT', 'REPLYTO')
    order by p.parameter_name;

    **************************************************
    4. check if processor_read_timeout_close is set to 'Y'
    set pagesize 100
    set linesize 132
    set feedback off
    set verify off

    col value format a35
    col component_name format a30

    select c.component_id, c.component_name, p.parameter_id, p.parameter_name, v.parameter_value value
    from apps.fnd_svc_comp_param_vals_v v, apps.fnd_svc_comp_params_b p, apps.fnd_svc_components c
    where c.component_type = 'WF_MAILER'
    and v.component_id = c.component_id
    and v.parameter_id = p.parameter_id
    and p.parameter_name = 'PROCESSOR_READ_TIMEOUT_CLOSE'
    order by c.component_name,p.parameter_name;

    **************************************************
    5. check for bad e-mail address

    If below SQL statement is returning rows you need to correct the email addresses for associated users:

    set linesize 170
    col name format a40
    col email_address format a80
    select name, email_address from apps.wf_local_roles where email_address like '% %';

    select name, email_address from apps.wf_local_roles where email_address like '%%';

    **************************************************
    6. How to know mail sent to a user with details:
    select name, display_name, notification_preference, email_address from wf_local_roles where name = '';

    **************************************************
    7. How to know whether it is set to correct url from porfile options:
    set linesize 155;
    set pagesize 200;
    set verify off;
    col Profile format a50;
    col Value format a50;
    select t.PROFILE_OPTION_ID ID, z.USER_PROFILE_OPTION_NAME Profile,
    nvl(v.PROFILE_OPTION_VALUE,'Replace with non-virtual URL') Value
    from apps.fnd_profile_options t, apps.fnd_profile_option_values v, apps.fnd_profile_options_tl z
    where (v.PROFILE_OPTION_ID (+) = t.PROFILE_OPTION_ID)
    and (z.PROFILE_OPTION_NAME = t.PROFILE_OPTION_NAME)
    and (t.PROFILE_OPTION_NAME in ('WF_MAIL_WEB_AGENT'));

    **************************************************
    8. How to know reqid, process id, sid..
    select request_id,phase_code,status_code,hold_flag from fnd_concurrent_requests where REQUEST_ID=20422815;

    select ORACLE_PROCESS_ID,ORACLE_SESSION_ID,OS_PROCESS_ID from fnd_concurrent_requests where REQUEST_ID=20422815;

    select a.session_id,
    b.owner,
    b.object_type,
    b.object_name,
    a.oracle_username,
    a.os_user_name,
    a.process,
    a.locked_mode
    from v$locked_object a, dba_objects b
    where b.object_id = a.object_id
    and a.session_id='3383';

    select name, display_name, notification_preference, email_address from wf_local_roles where name = 'SYSADMIN';


    **************************************************
    9. workflow patches  will provide us information as to your base line code level.
    Many issues are only relevant to a certain code level so this information is essential:

    set linesize 155;
    set pagesize 200;
    set verify off;
    select b.bug_number bug, b.LAST_UPDATED_BY ldate, decode( bug_number, 2728236 , 'OWF.G INCLUDED IN 11.5.9',
    3031977, 'POST OWF.G ROLLUP 1 - 11.5.9.1',
    3061871, 'POST OWF.G ROLLUP 2 - 11.5.9.2',
    3124460, 'POST OWF.G ROLLUP 3 - 11.5.9.3',
    3316333, 'POST OWF.G ROLLUP 4 - 11.5.9.4.1',
    3314376, 'POST OWF.G ROLLUP 5 - 11.5.9.5',
    3409889, 'POST OWF.G ROLLUP 5 Consolidated Fixes For OWF.G RUP 5', 3492743, 'POST OWF.G ROLLUP 6 - 11.5.9.6',
    3868138, 'POST OWF.G ROLLUP 7 - 11.5.9.7',
    3262919, 'FMWK.H',
    3262159, 'FND.H INCLUDE OWF.H',
    3258819, 'OWF.H INCLUDED IN 11.5.10',
    3438354, '11i.ATG_PF.H INCLUDE OWF.H',
    3140000, 'ORACLE APPLICATIONS RELEASE 11.5.10 MAINTENANCE PACK',
    3240000, '11.5.10 ORACLE E-BUSINESS SUITE CONSOLIDATED UPDATE 1',
    3460000, '11.5.10 ORACLE E-BUSINESS SUITE CONSOLIDATED UPDATE 2',
    3480000, 'ORACLE APPLICATIONS RELEASE 11.5.10.2 MAINTENANCE PACK',
    4017300, 'ATG_PF:11.5.10 Consolidated Update (CU1) for ATG Product Family',
    4125550, 'ATG_PF:11.5.10 Consolidated Update (CU2) for ATG Product Family',
    4719658, 'ONE OFF PATCH FOR MISSING RESPONSIBILITIES - WFDS Fix',
    5121512, 'AOL USER RESPONSIBILITY SECURITY FIXES VERSION 1',
    6008417, 'AOL USER RESPONSIBILITY SECURITY FIXES 2b',
    4676589, '11i.ATG_PF.H RUP4',
    5473858, '11i.ATG_PF.H RUP5',
    5903765, '11i.ATG_PF.H RUP6',
    4334965, '11i.ATG_PF.H RUP3') patch
    from apps.AD_BUGS b
    where b. BUG_NUMBER in ('2728236','3031977','3061871','3124460','3316333','3314376','3409889','3492743','3262159','3262919','3868138','3258819','3438354','3240000','3460000','3140000','3480000','4017300','4125550','4719658','5121512','6008417','4676589','5473858','5903765','4334965')
    order by patch;

    **************************************************
    10. Workflow: To see failed, open notifications
    SELECT message_type, COUNT(1)
    FROM apps.wf_notifications
    WHERE 1 = 1 AND mail_status = 'FAILED' AND status = 'OPEN'
    GROUP BY message_type;



    **************************************************
    11. To check if email address, notification preference, display_name


    select DISPLAY_NAME, NOTIFICATION_PREFERENCE from wf_users where EMAIL_ADDRESS = 'h@h.com' and STATUS = 'ACTIVE' and DISPLAY_NAME = 'xxxxx';

    select DISPLAY_NAME, NOTIFICATION_PREFERENCE, EMAIL_ADDRESS from wf_users where NOTIFICATION_PREFERENCE='MAILTEXT' and STATUS = 'ACTIVE';

    select distinct(count(*)) from wf_users where NOTIFICATION_PREFERENCE='MAILTEXT' and STATUS = 'ACTIVE' and EMAIL_ADDRESS = 'mmmmm@yahoo.com';

    **************************************************
    12. How to know workflow responsibility from backend:

    select wes.status, wes.phase, wes.rule_function, wes.on_error_code from wf_events we, wf_event_subscriptions wes
    where we.name='oracle.apps.fnd.wf.ds.userRole.updated' and we.guid=wes.event_filter_guid;

    **************************************************
    13. Steps to drop and recreate WF_CONTROL queue:

    a. Shut down the concurrent managers.

    b. Connect to sqlplus session as APPS user:
    Execute: (For Workflow Embedded within Apps)

    SQL>exec DBMS_AQADM.DROP_QUEUE_TABLE(queue_table => 'APPLSYS.WF_CONTROL', force =>TRUE);

    SQL> commit;

    Execute: (For Standalone Workflow)
    sqlplus / @wfctlqec.sql

    c. Execute wfjmsqc2.sql for creating all Advanced Queues with JMS Text structures.

    Usage:
    sqlplus / @wfjmsqc2.sql

    Both of the script are under $FND_TOP/patch/115/sql or $FND_TOP/sql directories.

    d.Run afwfqgnt.sql to recreate grants/synonyms for Workflow Advanced Queue tables
    **************************************************
    Usage:
    sqlplus apps/apps @$FND_TOP/patch/115/sql/afwfqgnt.sql APPS APPLSYS
    Additional Information: For Rebuilding all other WF Queue refer Note 754468.1 Title: How to Rebuild Workflow Queues ,based on your application version.

*********************************************************************************


Configuration for Workflow notification mailer setup in Oracle Applications R12

The main component of the Oracle Workflow Notification Mailer is the executable
WF-MAIL. This is a server side program that queries the database for any pending
notifications. It then dispatches these notifications by calling send-mail for UNIX and the MAPI APIs for Microsoft Windows NT. The notification mailer also queries the local inbox for incoming messages. These messages are validated and then passed to the database for response processing. To configure Workflow Notification Mailer we have to do OS level setup (Send-mail) and Application level setup.

1. OS Level Setup
2. Application level Configuration

1. OS (RHEL5.8) level Setup
At Os level we need to do bellow setups before configuring Application level
Sendmail should be installed by default when you install RedHat Linux. If it is not then you need to install the Sendmail RPM’s with the Red Hat distribution Sendmail RPM’s (In Linux 5.8) 

[root@sujeet ~]# rpm -qa |grep sendmail*
sendmail-8.13.8-8.1.el5_7
sendmail-cf-8.13.8-8.1.el5_7


1.Enable the SMTP and DEVECOT services
In order to configure Workflow notification mailer We need to enable theSMTP and DEVECOT services at the OS level.
Install Dovecot RPM if not installed 
[root@sujeet ~]# rpm -qa |grep dove*
dovecot-1.0.7-7.el5_7.1
Start the Dovecot services 

Start the services from Command 

[root@sujeet ~]# /etc/init.d/dovecot restart

Or 

Start Dovecot services from Server 
Navigation to enable these services
System –>Administration –> Server Settions–>Services



Start the dovecot services then save 
Check the Dovecot services 
[root@sujeet ~]# telnet 192.168.125.125 
2.Check SMTP and IMAP services
Check weather SMTP and IMAP services are working or not by using following command
#telnet <domain_name> smtp
#telnet <domain_name> imap
    1. If the above commands doesn’t start then Goto the below location
$cd /etc/mail/
Edit the file sendmail.mc and change DAEMON_OPTIONS as below
DAEMON_OPTIONS(‘port=25,Addr=192.168.125.125,Name=MTA’)dnl
2.2 Now configure a Mailserver in the OS as follows
2.2.1 Navigation
Applications—>Internet —>Email
Specify fullname: eg :applmgr
Email address :sonujha86@gmail.com
2.2.2 In the Receiving mail setup window specify the
Hostname : ceserp.computechcorp.net
Username : applmgr
click Forward
2.2.3 In the sending mail setup window specify
Hostname : ceserp.computechcorp.net
click Forward
      1. At last click on Apply to save the settings
3.Configuring WF_Mailer setup
Navigation:
Logon to Oracle Applications as System Adminstrator resposibility.
click on Workflow:Oracle Applications Manager : workflow manager
Note:Before configuring WorkflowNotification Mailer setup Make sure that we create two folders in our Mail account as
1.PROCESSED
2.DISCARD
If the WorkFlow MAILER is not configured in the the Oracle Applications then the following screen appears as Notification Mailers : Unavailable
–Start all the Concurrent Managers related to workflow..
/*Click on configuration components*/
Start all the available configuration service components
To Start all the available configuration service components
Go to Related Links –> Notification Mailers then start all services. Then click on
Notification Mailers : Unavailable
Then the following screen appears:
Click on edit.
Then there will be 8 steps to be complete the WF_MAIL configuration setup
1.DEFINE
Here nothing to do. Click on Next button.
2.DETAILS
Here based on the requirement change the values.For basic requirement no changes are needed.
Click on next.
3.EMail Servers
1. In General section.
Here no need to change the General section.
2. InBound EmailAccount section
specify
Inbound Protocol :IMAP
Inbound servername :ceserp.computechcorp.net
Username: applmgr
password : applmgr <password what we specified at OS level>.
3. Outbound MailAccount section
specify
Outbound Protocol : SMTP
Outbound servername: ceserp.computechcorp.net
Testaddress : bhanu.sanam@gmail.com
4. Email Processing secion
specify
Processed folder :PROCESSED
Discard folder : DISCARD
Then click on Next
4.MessageGeneration
From: u can specify u r own tag name
Reply-to Address :applmgr@ceserp.computechcorp.net
No need to change the rest of things
Click on Next.
5.schedule Events
Nothing to do Here .
Click on Next.
6.Tags
Nothing to do here .
Click on Next.
7.Test
Test the configuration by specifying the Recipient role:Application level User Name
(When Creating user we need to specify mail address field).Click on “send text message”.
click on Next
8.Review.
The above screens shows all the details what we configured till now.
Click on Finish to exit the setup.


COLD backup script using RMAN

Taking the backup of the database when db is down. But if we are using RMAN for backup we need to keep the database in mount state.

Copy the following contents to a file with name COLD_BACKUP_RMAN.rc

=============================================
run {
   shutdown immediate;
   startup mount;
   allocate channel dup1 device type disk;
   allocate channel dup2 device type disk;
   backup database;
   release channel dup1;
   release channel dup2;
   alter database open;
  }
=============================================

Now set the DB environment using your regular method then run the following command.

$ rman target / @COLD_BACKUP_RMAN.rc

Location of alert log in 11g.


SQL> select * from v$version; 

 BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production PL/SQL Release 11.1.0.7.0 - Production CORE    11.1.0.7.0      Production TNS for Linux: Version 11.1.0.7.0 - Production NLSRTL Version 11.1.0.7.0 - Production  

SQL>  show parameter background 

 NAME                                 TYPE        VALUE ------------------------------------ ----------- ------------------------------ background_core_dump                 string      partial background_dump_dest                 string      /u01/app/oracle/diag/rdbms/PROD/PROD/trace SQL> !ls -ltr /u01/app/oracle/diag/rdbms/PROD/PROD/trace/al* -rw-r----- 1 oracle oinstall 78512424 2011-10-03 02:00 /u01/app/oracle/diag/rdbms/PROD/PROD/trace/alert_PROD.log

SQL> select value from v$parameter where name='background_dump_dest';  

VALUE -------------------------------------------------------------------------------- 
/u01/app/oracle/diag/rdbms/orcl/orcl/trace -bash-3.2$ cd /u01/app/oracle/diag/rdbms/orcl/orcl/trace 

-bash-3.2$ ls alert_orcl.log orcl_j001_25686.trm orcl_ora_20641.trc

SQL> show parameter background_dump_dest;
By default its --> $diagnostic_dest/diag/rdbms/<db_unique_name>/<instance_name>/trace

SQL> desc v$diag_info;


Name                         Null? Type
----------------------------------------- -------- ----------------------------
INST_ID                         NUMBER
NAME                              VARCHAR2(64)
VALUE                              VARCHAR2(512)



SQL> select * from v$diag_info where name='Diag Alert';



INST_ID

1
------------------------------------------------------------------------------
NAME

Diag Alert

---------- ----------------------------------------------------------------
VALUE
--------------------------------------------------------------------------------

/u01/app/diag/rdbms/orcl/orcl/alert

----------------------------------------------------------------------------------

on bash comand line:

$ ls /u01/app/diag/rdbms/orcl/orcl/alert

result: log.xml

To find the location of the diagnostic_dest, can use the following select

SQL> select value from v$parameter where name='diagnostic_dest'; VALUE -------------------------------------------------------------------------------- /u01/app/oracle

To know the current ORACLE_SID, you can use following select:

SQL> select name from v$database; NAME --------- idea

Alert log file consist alert_<SID_NAME>.log

Therefore my alert log file is : /u01/app/oracle/diag/rdbms/orcl/orcl/trace/alert_orcl.log






ERROR 1396 (HY000): Operation ALTER USER failed for 'Mysql'@'%'

 This MySQL error — ERROR 1396 (HY000): Operation ALTER USER failed for 'Mysql'@'%' — means that MySQL cannot find the user ...