Anda di halaman 1dari 9

Tuning Buffer Busy Waits

16/08/2010

TCS FS/HYD/ SFMS-NEFT Project


Hari Krishna Pemmasani
hari.pemmasani@tcs.com

TCS Public
Title of the Document

- Note

This document is prepared in a step wise manner rather


following general indexing approach.Because the same can be
replicated.

Internal Use 2
Title of the Document

Step 1:-

Create a table which will have 3 columns of type number.

DROP TABLE test;


create table test(no1 integer,no2 integer,no3 integer) ;

Step 2:-

Create sequence to populate the columns

DROP SEQUENCE testseq1;


create sequence testseq1;

Step 3:- Create a procedure to insert the rows

create or replace procedure testone is


begin
for i in 1..600000 loop
insert into test values(testseq1.nextval,testseq1.nextval,testseq1.nextval);
end loop;
commit;
end;

Step 4: -
Using the below command I will check the no of freelists
In on the object test.

SQL> select FREELISTS from user_tables where TABLE_NAME='TEST';


FREELISTS
----------
1

Step 5:-
I have opened 3 new sessions and placed
The command
SQL>exec testone;

I have execute the procedure

SQL>exec statspack.snap;

Internal Use 3
Title of the Document

In prefsatat user.
Once I have run the above procedure ,I have started
Execute the procedure testone in all the 3 sessions.

After finishing the execution of the above 3 steps


I had again executed the statspack.snap procedure
In perfstat schema.

Some of the important block of the statspack report are

STATSPACK report for

DB Name DB Id Instance Inst Num Release Cluster Host


------------ ----------- ------------ -------- ----------- ------- ------------
SFMS 1694279656 sfms 1 9.2.0.1.0 NO SFMSEXT-EB30
F5F

Snap Id Snap Time Sessions Curs/Sess Comment


---------------------------------- -------- --------- -----------------------------------
Begin Snap: 15 16-Aug-10 08:48:31 18 3.7
End Snap: 16 16-Aug-10 08:54:14 17 3.9
Elapsed: 5.72 (mins)

Cache Sizes (end)


~~~~~~~~~~~~~~~~~
Buffer Cache: 24M Std Block Size: 8K
Shared Pool Size: 48M Log Buffer: 512K

Instance Efficiency Percentages (Target 100%)


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Buffer Nowait %: 72.70 Redo NoWait %: 99.90
Buffer Hit %: 100.00 In-memory Sort %: 100.00
Library Hit %: 100.00 Soft Parse %: 100.00
Execute to Parse %: 95.22 Latch Hit %: 98.01
Parse CPU to Parse Elapsd %: 91.06 % Non-Parse CPU: -558.82

Internal Use 4
Title of the Document

Top 5 Timed Events


~~~~~~~~~~~~~~~~~~ % Total
Event Waits Time (s) Ela Time
-------------------------------------------- ------------ ----------- -------------
buffer busy waits 370,202 1,488 48.00
log file switch (archiving needed) 1,182 1,217 39.24
control file sequential read 18,270 130 4.19
enqueue 107,882 61 1.98
log buffer space 216 49 1.57
---------------------------------------------------------------------------------

Buffer Pool Statistics for DB: SFMS Instance: sfms Snaps: 15 -16
-> Standard block size Pools D: default, K: keep, R: recycle
-> Default Pools for other block sizes: 2k, 4k, 8k, 16k, 32k

Free Write Buffer


Number of Cache Buffer Physical Physical Buffer Complete Busy
P Buffers Hit % Gets Reads Writes Waits Waits Waits
--- ---------- ----- ----------- ----------- ---------- ------- -------- ------------------------------
D 1,500 100.0 1,264,043 50 14,398 40 1 369,591
16k 759 0 0 0 0 0 0
------------------------------------------------------------------------------------------------------

Buffer wait Statistics for DB: SFMS Instance: sfms Snaps: 15 -16
-> ordered by wait time desc, waits desc

Tot Wait Avg


Class Waits Time (s) Time (ms)
------------------ ----------- ---------- --------------------
data block 369,964 1,072 3
undo header 433 414 956
segment header 202 0 0
-------------------------------------------------------------

Internal Use 5
Title of the Document

Enqueue activity for DB: SFMS Instance: sfms Snaps: 15 -16


-> Enqueue stats gathered prior to 9i should not be compared with 9i data
-> ordered by Wait Time desc, Waits desc

Avg Wt Wait
Eq Requests Succ Gets Failed Gets Waits Time (ms) Time (s)
-- ------------ ------------ ----------- ----------- ------------- ----------------------
SQ 151,567 151,565 0 100,096 .41 41
HW 2,374 2,374 0 1,435 9.77 14
CF 5,949 5,943 6 30 221.27 7
TX 53,025 53,025 0 33 .48 0
----------------------------------------------------------------------------------------

From the above stataspack report we can observe the Buffer Nowait %
is just 72% ,the Buffer Busy waits in the top 5 wait events and
Buffer Bussy waits in Buffer Pool Statistics.It is clear from the
Buffer wait Statistics the wait is on the datablock..

So,I will just try to increase the freelists of the object test to 3
Since I am executing the same procedure from 3 different sessions
On the same table.

SQL> alter table test storage (freelists 3);


Table altered.

We will check once again wheather the parameter is changed or not.

SQL> select FREELISTS from user_tables where TABLE_NAME='TEST';


FREELISTS
----------
1
After increasing the freelists from one to 3,I will just do the same
Exercise as we have done earlier

I have opened 3 new sessions and placed The command


SQL>exec testone;

I have execute the procedure SQL>exec statspack.snap;


In prefsatat user.

Once I have run the above procedure ,I have started

Internal Use 6
Title of the Document

Execute the procedure testone in all the 3 sessions.

After finishing the execution of the above 3 steps


I had again executed the statspack.snap procedure
In perfstat schema.

Some of the important block of the statspack report are

DB Name DB Id Instance Inst Num Release Cluster Host


------------ ----------- ------------ -------- ----------- ------- ------------
SFMS 1694279656 sfms 1 9.2.0.1.0 NO SFMSEXT-EB30
F5F

Snap Id Snap Time Sessions Curs/Sess Comment


------- -------------------------- -------------------------------------------------------
Begin Snap: 17 16-Aug-10 09:04:55 18 4.6
End Snap: 18 16-Aug-10 09:07:08 18 4.7
Elapsed: 2.22 (mins)

Cache Sizes (end)


~~~~~~~~~~~~~~~~~
Buffer Cache: 24M Std Block Size: 8K
Shared Pool Size: 48M Log Buffer: 512K

Instance Efficiency Percentages (Target 100%)


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Buffer Nowait %: 100.00 Redo NoWait %: 100.00
Buffer Hit %: 100.00 In-memory Sort %: 100.00
Library Hit %: 100.00 Soft Parse %: 100.00
Execute to Parse %: 95.22 Latch Hit %: 97.70
Parse CPU to Parse Elapsd %: 97.49 % Non-Parse CPU: 98.25

Top 5 Timed Events


~~~~~~~~~~~~~~~~~~ % Total
Event Waits Time (s) Ela Time
-------------------------------------------- ------------ ----------- -------------
CPU time 133 25.01
log buffer space 1,069 104 19.51
enqueue 169,004 79 14.89
db file parallel write 596 54 10.13
free buffer waits 105 41 7.71
----------------------------------------------------------------------------------

Internal Use 7
Title of the Document

Buffer Pool Statistics for DB: SFMS Instance: sfms Snaps: 17 -18
-> Standard block size Pools D: default, K: keep, R: recycle
-> Default Pools for other block sizes: 2k, 4k, 8k, 16k, 32k

Free Write Buffer


Number of Cache Buffer Physical Physical Buffer Complete Busy
P Buffers Hit % Gets Reads Writes Waits Waits Waits
--- ----------------------------------------------------------------------------------------------
D 1,500 100.0 2,131,189 58 23,105 105 34 19
16k 759 0 0 0 0 0 0
-------------------------------------------------------------------------------------------------

Buffer wait Statistics for DB: SFMS Instance: sfms Snaps: 17 -18
-> ordered by wait time desc, waits desc

Tot Wait Avg


Class Waits Time (s) Time (ms)
------------------ ----------- ---------- -------------------
segment header 18 0 0
undo header 1 0 0
-------------------------------------------------------------

Enqueue activity for DB: SFMS Instance: sfms Snaps: 17 -18


-> Enqueue stats gathered prior to 9i should not be compared with 9i data
-> ordered by Wait Time desc, Waits desc

Avg Wt Wait
Eq Requests Succ Gets Failed Gets Waits Time (ms) Time (s)
------------------------------------------------------------------------------------------
SQ 257,285 257,285 0 168,992 .46 78
HW 1,254 1,254 0 7 95.86 1
CF 116 116 0 1 16.00 0
TX 90,350 90,350 0 4 .00 0
-----------------------------------------------------------------------------------------

From the above statspack report it shows that the buffer busy waits
were gone.The above report also shows other 2 wait events
enqueue and free buffer waits.Enqueue wait event with SQ reason
is due the oracle sequence.Free buffer waits might be due to
DBWR might not be able to get the free buffers
to write the data.

Internal Use 8
Title of the Document

Conclusion:-

From the above test we came to know how to tune the Buffer Busy
Wait caused by the freelists.The same wait event can also be caused due
the the lesser sizing of
the db_cache_size.In that case please monitor the parameter Buffer
Busy Nowait,Buffer Hit Ratio Parameter in the instance ratio’s of
statspack report.

Also note that too much increase in the no of freelists may cause
the usage
of index costly.Because for each time an insert happens it looks for the
block in
the segment free list(May be ITL) since at any time we will have n no of
freelists(n is the no of freelists).Each insert will write data into different
block.So when an index
is created on the above columns the clustering_factor(The no of block
switches required to scan a table.Usually a good index will have no of
table blocks plus one) may increase dramtically.Which leads to non usage
of index.

Internal Use 9