Professional Documents
Culture Documents
Performacne Tuning Vol2-3
Performacne Tuning Vol2-3
The objective of this practice is to use available diagnostic tools to monitor and tune the
database buffer cache.
1. Connect as perfstat/perfstat user, and run a statistic snapshot, and note the snapshot
number.
SQL> connect perfstat/perfstat
SQL> @$HOME/STUDENT/LABS/snap.sql
2. To simulate user activity against the database, connect as hr/hr user and run the
lab04_02.sql script.
SQL> connect hr/hr
SQL> @$HOME/STUDENT/LABS/lab04_02.sql
3. Connect as system/manager and measure the hit ratio for the database buffer cache
using the v$sysstat view. Determine if it is a good ratio or not.
To query the V$SYSSTAT view:
SQL> SELECT 1 - (phy.value – lob.value – dir.value)
2> / ses.value "CACHE HIT RATIO“
3> FROM v$sysstat ses, v$sysstat lob,
4> v$sysstat dir, v$sysstat phy
5> WHERE ses.name = 'session logical reads‘
6> AND dir.name = ‘physical reads direct‘
7> AND lob.name = 'physical reads direct (lob)‘
8> AND phy.name = 'physical reads';
4. Connect as perfstat/perfstat, and run a statistic snapshot, and note the snapshot number.
This can be performed by running the script file $HOME/STUDENT/LABS/snap.sql.
SQL> connect perfstat/perfstat
SQL> @$HOME/STUDENT/LABS/snap.sql
5. Use the report from Statspack between the last two snapshots to check the buffer cache
hit ratio, using the script $HOME/STUDENT/LABS/spreport.sql. Then analyze the
buffer hit % in the “Instance Efficiency Percentages” section.
SQL> @$HOME/STUDENT/LABS/spreport.sql
Note: On a production database if the ratio is bad, add new buffers, run steps 2 to 5, and
examine the new ratio to verify that the ratio has improved. If the ratio is good, remove
buffers, run steps 2 to 5, and verify if the ratio is still good.