Wednesday, 11 April 2012

Guide to Use this blog

> Start with "first post" to start reading on performance tuning ==steps to top down approach in performance tuning..
> Frequently Asked topics == this post needs to be updated with the internal links and highlights of each topic
>Format all posts and highlight important points

Wednesday, 14 March 2012

Server Tuning

iostat (disk)
vmstat (RAM)
netstat(network)
top(CPU)  and prstat
SAR

iostat stands for input output statistics and reports statistics for i/o devices such as disk drives .
vmstat gives the statistics for virtual Memory and
netstat gives the network statstics .

Tuesday, 15 March 2011

Input Output statistics ( iostat )

iostat reports
>terminal and disk I/O activity and
>CPU utilization.

iostat’s activity class options default to tdc (terminal, disk, and CPU).

The values to look from the iostat output are:* Reads/writes per second (r/s , w/s)
* Percentage busy (%b)
* Service time (svc_t)

 If a disk shows consistently high reads/writes along with ,
the percentage busy (%b) of the disks is greater than 5 percent, and
the average service time (svc_t) is greater than 30 milliseconds,
then one of the following action needs to be taken

1.) Tune the application to use disk i/o more efficiently by modifying the disk queries and using available cache facilities of application servers .

2.) Spread the file system  of the disk on to two or more disk using disk striping feature of volume manager /disksuite etc.

3.) Increase the system parameter  values for inode cache , ufs_ninode , which is Number of inodes to be held in memory. Inodes are cached globally (for UFS), not on a per-file system basis

4.) Move the file system to another faster disk /controller or replace existing disk/controller to a faster one.

Tuesday, 15 February 2011

VMSTAT

vmstat stands for virtual memory statistics;

It collects and displays summary information about
memory,
processes,
 interrupts,
 paging and
 block I/O information.

By specifying the interval, it can be used to observe system activity interactively.
Most commonly people will use 2 numeric arguments in vmstat;
first is delay or sleep between updates and
the second is how many updates you want to see before vmstat quits.
Please note this is not the full syntax of vmstat and also it can vary between OSs. Please refer your OS man page for more information.
To run vmstat with 7 updates, 10 seconds apart type
#vmstat 10 7

Monday, 14 February 2011

TOP , PRSTAT , LOAD Average

TOP

TOP command is use to see the process status..But it is not
used in solaris 10 in solaris 10 it is replaced by prstat

top for checking the current system status like process,cpu
and memory...
if you want to run in Solaris.we need add the pkg.
the pkg is "SUNW SMCtop".
PRSTAT

you can use prstat to identify which processes are consuming the CPU resources. The prstat -s cpu -n 5 command is used to list the five processes that are consuming the most CPU resources. The -s cpu flag tells prstat to sort the output by CPU usage. The -n 5 flag tells prstat to restrict the output to the top five processes.
$ prstat -s cpu -n 5


Load Average::

For example, one can interpret a load average of "1.73 0.50 7.98" on a single-CPU system as:
·         during the last minute, the CPU was overloaded by 73% (1 CPU with 1.73 runnable processes, so that 0.73 processes had to wait for a turn)
·         during the last 5 minutes, the CPU was underloaded 50% (no processes had to wait for a turn)
·         during the last 15 minutes, the CPU was overloaded 698% (1 CPU with 7.98 runnable processes, so that 6.98 processes had to wait for a turn)
This means that this CPU could have handled all of the work scheduled for the last minute if it were 1.73 times as fast, or if there were two (the ceiling of 1.73) times as many CPUs, but that over the last five minutes it was twice as fast as necessary to prevent runnable processes from waiting their turn.
In a system with four CPUs, a load average of 3.73 would indicate that there were, on average, 3.73 processes ready to run, and each one could be scheduled into a CPU

Sunday, 13 February 2011

SAR

The SAR suite of utilities originated in Solaris. It became popular and now runs on most flavors of UNIX, including AIX, HP-UX, and Linux.
(System Activity Reporter)

The reason for sar creation was that gathering system activity data from vmstat and iostat is pretty time-consuming. If you try to automate the gathering of system activity data, and creation of periodic repots you naturally come to creation of a tool like sar.

System Activity Recorder can monitor half-dozen metrics related to overall system performance, for example:
cpu utilization (it's pretty effective tool for spotting CPU bottlenecks)
hard disk utilization
terminal IO
number of files open
      processes running

Saturday, 12 February 2011

Automatic Workload Repository (AWR) in Oracle Database 10g

In Oracle 10g statspack has evolved into the Automatic Workload Repository (AWR).

AWR Features

The AWR is used to collect performance statistics including:
  • Wait events used to identify performance problems.
  • Time model statistics indicating the amount of DB time associated with a process from the V$SESS_TIME_MODEL and V$SYS_TIME_MODEL views.
  • Active Session History (ASH) statistics from the V$ACTIVE_SESSION_HISTORY view.
  • Some system and session statistics from the V$SYSSTAT and V$SESSTAT views.
  • Object usage statistics.
  • Resource intensive SQL statements.
The repository is a source of information for several other Oracle 10g features including:
  • Automatic Database Diagnostic Monitor
  • SQL Tuning Advisor
  • Undo Advisor
  • Segment Advisor

Snapshots

By default snapshots of the relevant data are taken every hour and retained for 7 days. The default values for these settings can be altered using:
BEGIN
  DBMS_WORKLOAD_REPOSITORY.modify_snapshot_settings(
    retention => 43200,        -- Minutes (= 30 Days). Current value retained if NULL.
    interval  => 30);          -- Minutes. Current value retained if NULL.
END;
/
The changes to the settings are reflected in the DBA_HIST_WR_CONTROL view.

Automatic collection is only possible if the STATISTICS_LEVEL parameter is set to TYPICAL or ALL. If the value is set to BASIC manual snapshots can be taken, but they will be missing some statistics.

Extra snapshots can be taken and existing snapshots can be removed using:
EXEC DBMS_WORKLOAD_REPOSITORY.create_snapshot;
BEGIN
  DBMS_WORKLOAD_REPOSITORY.drop_snapshot_range (
    low_snap_id  => 22, 
    high_snap_id => 32);
END;
/
Snapshot information can be queried from the DBA_HIST_SNAPSHOT view.

Baselines

A baseline is a pair of snapshots that represents a specific period of usage. Once baselines are defined they can be used to compare current performance against similar periods in the past. You may wish to create baseline to represent a period of batch processing like:
BEGIN
  DBMS_WORKLOAD_REPOSITORY.create_baseline (
    start_snap_id => 210, 
    end_snap_id   => 220,
    baseline_name => 'batch baseline');
END;
/
The pair of snapshots associated with a baseline are retained until the baseline is explicitly deleted:
BEGIN
  DBMS_WORKLOAD_REPOSITORY.drop_baseline (
    baseline_name => 'batch baseline',
    cascade       => FALSE); -- Deletes associated snapshots if TRUE.
END;
/
Baseline information can be queried from the DBA_HIST_BASELINE view.

Workload Repository Views

The following workload repository views are available:
  • V$ACTIVE_SESSION_HISTORY - Displays the active session history (ASH) sampled every second.
  • V$METRIC - Displays metric information.
  • V$METRICNAME - Displays the metrics associated with each metric group.
  • V$METRIC_HISTORY - Displays historical metrics.
  • V$METRICGROUP - Displays all metrics groups.
  • DBA_HIST_ACTIVE_SESS_HISTORY - Displays the history contents of the active session history.
  • DBA_HIST_BASELINE - Displays baseline information.
  • DBA_HIST_DATABASE_INSTANCE - Displays database environment information.
  • DBA_HIST_SNAPSHOT - Displays snapshot information.
  • DBA_HIST_SQL_PLAN - Displays SQL execution plans.
  • DBA_HIST_WR_CONTROL - Displays AWR settings.

Workload Repository Reports

Oracle provide two scripts to produce workload repository reports (awrrpt.sql and awrrpti.sql). They are similar in format to the statspack reports and give the option of HTML or plain text formats. The two reports give essential the same output but the awrrpti.sql allows you to select a single instance. The reports can be generated as follows:
@$ORACLE_HOME/rdbms/admin/awrrpt.sql
@$ORACLE_HOME/rdbms/admin/awrrpti.sql
The scripts prompt you to enter the report format (html or text), the start snapshot id, the end snapshot id and the report filename. The resulting report can be opend in a browser or text editor accordingly.

Enterprise Manager

The automated workload repository administration tasks have been included in Enterprise Manager.

The "Automatic Workload Repository" page is accessed from the main page by clicking on the "Administration" link,
then the "Workload Repository" link under the "Workload" section.

The page allows you to modify AWR settings or manage snapshots without using the PL/SQL APIs.

Source: Link

Thursday, 10 February 2011

Oracle Active Session History (ASH)

Oracle Database 10g now collects the Active Session History (ASH) statistics (mostly the wait statistics for different events) for all active sessions every second, and stores them in a circular buffer in the SGA.
The ASH feature uses about 2MB of SGA memory per CPU.
Current Active Session Data
V$ACTIVE_SESSION_HISTORY enables you to access the ASH statistics. A database session is considered active if it was on the CPU or was waiting for an event that didn’t belong to the Idle wait class (indicated by SESSION_STATE column).
DBA_HIST_ACTIVE_SESSION_HISTORY View
This view in fact is a collection of snapshots from the V$ACTIVE_SESSION_HISTORY view. It is populated either by MMON during its regular snapshot capturing or by MMNL when the memory buffer is full.
Generate ASH Reports
In Oracle Release 2, you can generate ASH Report.
Some of the information it shows are top wait events, top SQL, top SQL command types, and top sessions, among others.
On Database Control:
Performance -> Run ASH Report button
On SQL*Plus:
Run the following script
$ORACLE_HOME/rdbms/admin/ashrpt.sql

Source:Link

Wednesday, 9 February 2011

Automatic Database Diagnostic Monitor (ADDM) in Oracle Database 10g

Overview

The Automatic Database Diagnostic Monitor (ADDM) analyzes data in the Automatic Workload Repository (AWR) to identify potential performance bottlenecks. For each of the identified issues it locates the root cause and provides recommendations for correcting the problem. An ADDM analysis task is performed and its findings and recommendations stored in the database every time an AWR snapshot is taken provided the STATISTICS_LEVEL parameter is set to TYPICAL or ALL.

The ADDM analysis includes:
  • CPU load
  • Memory usage
  • I/O usage
  • Resource intensive SQL
  • Resource intensive PL/SQL and Java
  • RAC issues
  • Application issues
  • Database configuration issues
  • Concurrency issues
  • Object contention
The findings (problems) are listed in order of potential impact on database performance, along with recommendations to resolve the issue and the symptoms which lead to it's discovery.

An example from my test instance is:
FINDING 1: 59% impact (944 seconds)
-----------------------------------
The buffer cache was undersized causing significant additional read I/O.
   RECOMMENDATION 1: DB Configuration, 59% benefit (944 seconds)
      ACTION: Increase SGA target size by increasing the value of parameter
         "sga_target" by 28 M.
   SYMPTOMS THAT LED TO THE FINDING:
      Wait class "User I/O" was consuming significant database time. (83%
      impact [1336 seconds])

The recommendations may include:
  • Hardware changes
  • Database configuration changes
  • Schema changes
  • Application changes
  • Using other advisors
The analysis of I/O performance is affected by the DBIO_EXPECTED parameter which should be set to the average time (in microseconds) it takes to read a single database block from disk. Typical values range from 5000 to 20000 microsoconds.

The parameter can be set using:
EXECUTE DBMS_ADVISOR.set_default_task_parameter('ADDM', 'DBIO_EXPECTED', 8000);

Enterprise Manager

The obvious place to start viewing ADDM reports is Enterprise Manager. The "Performance Analysis" section on the "Home" page is a list of the top five findings from the last ADDM analysis task.

Specific reports can be produced by clicking on the "Advisor Central" link, then the "ADDM" link. The resulting page allows you to select a start and end snapshot, create an ADDM task and display the resulting report by clicking on a few links.

addmrpt.sql Script

The addmrpt.sql script can be used to create an ADDM report from SQL*Plus. The script is called as follows:
-- UNIX
@/u01/app/oracle/product/10.1.0/db_1/rdbms/admin/addmrpt.sql
-- Windows
@d:\oracle\product\10.1.0\db_1\rdbms\admin\addmrpt.sql
It then lists all available snapshots and prompts you to enter the start and end snapshot along with the report name.

DBMS_ADVISOR

The DBMS_ADVISOR package can be used to create and execute any advisor tasks, including ADDM tasks. The following example shows how it is used to create, execute and display a typical ADDM report:
BEGIN
  -- Create an ADDM task.
  DBMS_ADVISOR.create_task (
    advisor_name      => 'ADDM',
    task_name         => '970_1032_AWR_SNAPSHOT',
    task_desc         => 'Advisor for snapshots 970 to 1032.');
  -- Set the start and end snapshots.
  DBMS_ADVISOR.set_task_parameter (
    task_name => '970_1032_AWR_SNAPSHOT',
    parameter => 'START_SNAPSHOT',
    value     => 970);
  DBMS_ADVISOR.set_task_parameter (
    task_name => '970_1032_AWR_SNAPSHOT',
    parameter => 'END_SNAPSHOT',
    value     => 1032);
  -- Execute the task.
  DBMS_ADVISOR.execute_task(task_name => '970_1032_AWR_SNAPSHOT');
END;
/
-- Display the report.
SET LONG 100000
SET PAGESIZE 50000
SELECT DBMS_ADVISOR.get_task_report('970_1032_AWR_SNAPSHOT') AS report
FROM   dual;
SET PAGESIZE 24
The value for the SET LONG command should be adjusted to allow the whole report to be displayed.

The relevant AWR snapshots can be identified using the
DBA_HIST_SNAPSHOT view.

Related Views

The following views can be used to display the ADDM output without using Enterprise Manager or the GET_TASK_REPORT function:
  • DBA_ADVISOR_TASKS - Basic information about existing tasks.
  • DBA_ADVISOR_LOG - Status information about existing tasks.
  • DBA_ADVISOR_FINDINGS - Findings identified for an existing task.
  • DBA_ADVISOR_RECOMMENDATIONS - Recommendations for the problems identified by an existing task.
Source: Link

Tuesday, 8 February 2011

cache hit ratio

Buffer cache hit ratio:

"The buffer cache hit ratio can be used to verify the physical I/O as predicted by V$DB_CACHE_ADVICE"
Oracle has the v$db_cache_advice utility and has incorporated a buffer cache advisory into the standard AWR report, ostensibly to provide recommendations about the projected reduction in expensive disk I/O with the addition  of more data buffers.

Hence, on the margin, the data buffer cache advisory is inaccurate for database with an undersized db_cache_size (and db_keep_cache_size, etc.). 

The following query can be used to perform the cache advice function, once the db_cache_advice has been enabled and the database has run long enough to give representative results.
-- ***********************************************************
-- Display cache advice
-- ***********************************************************
 
 
column c1   heading 'Cache Size (meg)'      format 999,999,999,999 
 
select
   size_for_estimate          c1,
   buffers_for_estimate       c2,
   estd_physical_read_factor  c3,
   estd_physical_reads        c4
from
   v$db_cache_advice
where
   name = 'DEFAULT'
and
   block_size  = (SELECT value FROM V$PARAMETER
                   WHERE name = 'db_block_size')
and
   advice_status = 'ON';
The output from the script is shown below.  Note that the values range from 10 percent of the current size to double the current size of the db_cache_size.
                                Estd Phys    Estd Phys
 Cache Size (meg)     Buffers Read Factor        Reads
---------------- ------------ ----------- ------------
              30        3,802       18.70  192,317,943 <== 10% size
              60        7,604       12.83  131,949,536
              91       11,406        7.38   75,865,861
             121       15,208        4.97   51,111,658
             152       19,010        3.64   37,460,786
             182       22,812        2.50   25,668,196
             212       26,614        1.74   17,850,847
             243       30,416        1.33   13,720,149
             273       34,218        1.13   11,583,180
             304       38,020        1.00   10,282,475 <== Current Size
             334       41,822         .93    9,515,878
             364       45,624         .87    8,909,026
             395       49,426         .83    8,495,039
             424       53,228         .79    8,116,496
             456       57,030         .76    7,824,764
             486       60,832         .74    7,563,180
             517       64,634         .71    7,311,729
             547       68,436         .69    7,104,280
             577       72,238         .67    6,895,122
             608       76,040         .66    6,739,731 <== 2x size
From the above listing we see that increasing the db_cache_size from 304 meg to 334 meg would result in approximately 700,000 less physical reads.  This can be plotted as a 1/x function and the exact optimal point computed as the second derivative of the function:


The Buffer Cache Hit Ratio Oracle metric monitors the rate at which Oracle finds the data blocks it needs in memory over the lifetime of an instance.

"many DBAs do their best to get a 99% or better hit ratio, but quickly discover that the performance of their database isn't improving as the hit ratio gets better," therefore, sometimes these statistics can be misleading. However, you can try, "the Oracle Wait Interface (OWI)" for better tuning.
we can use this query
SELECT NAME, PHYSICAL_READS, DB_BLOCK_GETS, CONSISTENT_GETS,
1 - (PHYSICAL_READS / (DB_BLOCK_GETS + CONSISTENT_GETS)) "Hit Ratio"
FROM V$BUFFER_POOL_STATISTICS;
to learn more about the buffer pool hit ratios.

you have
the default pool
the keep pool
and the recycle pool
When people refer to the buffer cache they usually refer to the default pool
KEEP pool - typically used for objects you want to keep permanently cached. After a warm-up period you hope that every access to an object in this pool is met from the buffer, so the KEEP hit ratio should be 100% if you're using it as you expect.

RECYCLE pool - typically used for objects that are such a nuisance that you can't hope to get any reasonable caching effect for them, but they still knock something out of memory when you read the blocks. You expect the RECYCLE hit ratio to 0% - if you're using it "properly".

DEFAULT pool - whatever you think your hit ratio should be for this pool, the figure is going to be clouded if you sum in the buffer gets and physical blocks read for the other buffer pools.
http://www.dba-oracle.com/m_library_cache_hit_ratio.htm

Oracle Library Cache Hit Ratio

The Library Cache Hit Ratio Oracle metric monitors the percentage of entries in the library cache that were parsed more than once (reloads) over the lifetime of the instance. 
Since you never know in-advance how many SQL statements need to be cached, the Oracle DBA must set shared_pool_size large enough to prevent excessive re-parsing of SQL.
the library cache hit ratio and error code ORA-0403. 
 It states that adjusting the shared pool size may help avoid this error.
To do this, we evaluate the library cache hit ratio metric as such; "The hit ratio helps to measure the usage of the shared pool based on how many times a SQL/PLSQL statement needed to be parsed instead of being reused. The following SQL statement help you to calculate the library cache hit ratio:

SELECT
   SUM(PINS) "EXECUTIONS",
   SUM(RELOADS) "CACHE MISSES WHILE EXECUTING"
FROM
   V$LIBRARYCACHE;


If the ratio of misses to executions is more than 1%, then try to reduce the library cache misses by increasing the shared pool size. "
Don't even bother trying to tune the Buffer Hit Ratio!
There are better ways to tune now. The Oracle Wait Interface (OWI) provides exact details.

Hit/Miss Ratios

Buffer Hit Ratio

BUFFER HIT RATIO NOTES:
·  Consistent Gets - The number of accesses made to the block buffer to retrieve data in a consistent mode.
·  DB Blk Gets - The number of blocks accessed via single block gets (i.e. not through the consistent get mechanism).
·  Physical Reads - The cumulative number of blocks read from disk.
·  Logical reads are the sum of consistent gets and db block gets.
·  The db block gets statistic value is incremented when a block is read for update and when segment header blocks are accessed.

·  Hit Ratio should be > 80%, else increase DB_BLOCK_BUFFERS in init.ora

·  select       sum(decode(NAME, 'consistent gets',VALUE, 0)) "Consistent Gets",
        sum(decode(NAME, 'db block gets',VALUE, 0)) "DB Block Gets",
        sum(decode(NAME, 'physical reads',VALUE, 0)) "Physical Reads",
        round((sum(decode(name, 'consistent gets',value, 0)) + 
               sum(decode(name, 'db block gets',value, 0)) - 
               sum(decode(name, 'physical reads',value, 0))) / 
              (sum(decode(name, 'consistent gets',value, 0)) + 
               sum(decode(name, 'db block gets',value, 0))) * 100,2) "Hit Ratio"
from   v$sysstat

Data Dict Hit Ratio

DATA DICTIONARY HIT RATIO NOTES:
·  Gets - Total number of requests for information on the data object.
·  Cache Misses - Number of data requests resulting in cache misses
·  Hit Ratio should be > 90%, else increase SHARED_POOL_SIZE in init.ora
select  sum(GETS),
        sum(GETMISSES),
        round((1 - (sum(GETMISSES) / sum(GETS))) * 100,2)
from    v$rowcache

SQL Cache Hit Ratio

SQL CACHE HIT RATIO NOTES:
·  Pins - The number of times a pin was requested for objects of this namespace.
·  Reloads - Any pin of an object that is not the first pin performed since the object handle was created, and which requires loading the object from disk.
·  Hit Ratio should be > 85%
select  sum(PINS) Pins,
        sum(RELOADS) Reloads,
        round((sum(PINS) - sum(RELOADS)) / sum(PINS) * 100,2) Hit_Ratio
from    v$librarycache

Library Cache Miss Ratio

LIBRARY CACHE MISS RATIO NOTES:
·  Executions - The number of times a pin was requested for objects of this namespace.
·  Cache Misses - Any pin of an object that is not the first pin performed since the object handle was created, and which requires loading the object from disk.
·  Hit Ratio should be < 1%, else increase SHARED_POOL_SIZE in init.ora
select  sum(PINS) Executions,
        sum(RELOADS) cache_misses,
        sum(RELOADS) / sum(PINS) miss_ratio
from    v$librarycache