|
Replies:
19
-
Pages:
2
[
1
2
| Next
]
-
Last Post:
Jul 12, 2007 2:34 PM
Last Post By: pdshah
|
|
|
Posts:
75
Registered:
03/17/00
|
|
|
|
Multiple Buffer
Posted:
Jun 25, 2007 1:50 PM
|
|
|
|
Hi,
I want to set up multiple buffer pool as we have currently onle one buffer pool 'DEFAULT'.
How I can Identify that which objects will go into KEEP or RECYCLE or DEFAULT?
I read some docs and founf following scripts but still confused?
I need really guidelines before I implement it.
for KEEP Buffer Pool Objects Query:
SELECT o.owner, object_name, object_type, COUNT(1) buffers
FROM x$bh, dba_objects o
WHERE tch > 10
AND lru_flag = 8
AND obj = o.object_id
AND o.owner not in ('SYSTEM','SYS')
GROUP BY o.owner, object_name, object_type
ORDER BY buffers;
Another KEEP Buffer Pool Objects Query:
SELECT owner, object_name, object_type, obj, count(file#)
FROM x$bh, dba_objects o
WHERE x$bh.obj = O.object_id
and o.owner not in ('SYS','SYSTEM')
and status != 'free'
GROUP BY o.owner, object_name, object_type, obj
order by count(file#) DESC;
For Recycle Buffer Pool Objects Query:
SELECT o.owner, object_name, object_type, COUNT(1) buffers
FROM x$bh, dba_objects o
WHERE (tch = 1 OR (tch = 0 AND lru_flag < 8))
AND obj = o.object_id
AND o.owner not in ('SYSTEM','SYS')
GROUP BY o.owner, object_name, object_type
ORDER BY buffers;
I also ran the following query to analysis of those objects in the data buffers means its lists the tables and indexes that reside inside the data buffer but little confused that what should be consider that which one goes into KEEP or RECYCLE ?
SELECT t1.owner "OWNER",
object_name "Object_Name",
CASE WHEN object_type = 'TABLE PARTITION' THEN 'TAB PART'
WHEN object_type = 'INDEX PARTITION' THEN 'IDX PART'
ELSE object_type END Object_Type,
SUM(num_blocks) "Num of Blocks in Buffer Cache",
(SUM(num_blocks)/GREATEST(SUM(blocks), .001))*100 "% of Blocks in Buffer Cache",
BUFFER_POOL "Buffer Pool",
SUM(bytes)/SUM(blocks) "Block Size"
FROM
(SELECT o.owner owner,
o.object_name object_name,
o.subobject_name subobject_name,
o.object_type object_type,
COUNT(DISTINCT FILE# || BLOCK#) num_blocks
FROM dba_objects o, v$bh bh
WHERE o.data_object_id = bh.objd AND o.owner NOT IN ('SYS','SYSTEM')
AND bh.status != 'free'
GROUP BY o.owner, o.object_name, o.subobject_name, o.object_type) T1
, dba_segments S
WHERE s.segment_name = t1.object_name
AND s.owner = t1.owner
AND s.segment_type = t1.object_type
AND NVL(s.partition_name,'-') = NVL(t1.subobject_name,'-')
GROUP BY t1.owner, object_name, object_type, BUFFER_POOL
HAVING SUM(num_blocks) > 10
ORDER BY SUM(num_blocks) DESC
Thanks,
|
|
|
Posts:
4,753
Registered:
11/24/00
|
|
|
|
Re: Multiple Buffer
Posted:
Jun 25, 2007 2:05 PM
in response to: pdshah
|
|
|
|
There is no thumb rule and the setting differs one database to another as it depends on application usage and demand.
Usually, you can keep small (static) tables (lookup tables) where frequently has FTS.
Jaffar
|
|
|
Posts:
2,343
Registered:
05/06/98
|
|
|
|
Re: Multiple Buffer
Posted:
Jun 25, 2007 2:30 PM
in response to: pdshah
|
|
|
Hi,
Yes, there is no one-sized fits-all approach, and I don't often assign blocks to the recycle pool, as Oracle does a good job without my help.
Are you examining candidates for a 32k data buffer? It's great for indexes that experience multi-block I/O (Index FFSand index range scans):
http://www.dba-oracle.com/oracle_tips_multiple_blocksizes.htm
Here are my rules for KEEP pool assignment, and I automate the whole thing with scripts:
http://www.dba-oracle.com/bp/teaser_sga_keep_pool.htm
The placement criteria for tables and indexes into the KEEP buffer are straightforward:
· Small tables – Parameters may be adjusted in the script based upon needs.
· Experiences full-table scans – Oracle designates the table as small and chooses a full-table scan over an index access.
· Frequently-accessed tables – The threshold for access can be adjusted in the script.
· High buffer residency – Any table that has more than 80% of its blocks in the data buffer should be cached in the KEEP pool .
There are two approaches to identifying tables for the KEEP pool
1. Tables (and associated indexes) that are small and have frequent full-table scans
2. Objects that have more than 80% of their data blocks in the buffer
Hope this helps. . .
Donald K. Burleson
Oracle Press author
|
|
|
Posts:
534
Registered:
09/10/98
|
|
|
|
Re: Multiple Buffer
Posted:
Jun 25, 2007 2:31 PM
in response to: The Human Fly
|
|
|
|
Well, Jaffar is correct, that there is no hard and fast rule. As with everything in Oracle, it depends. However, here's a script, and some thoughts, after using this feature for quite some time...
Here's the query I call "high_io_default_pool_segments.sql", that I use:
set lines 150
select * from(
with segstat as
(
select object_type,
object_name,
owner,
subobject_name,
max(case statistic_name when 'physical reads' then value end) pr,
max(case statistic_name when 'physical reads direct' then value end) prd
from v$segment_statistics vss
where statistic_name in ('physical reads', 'physical reads direct')
group by object_type, object_name, owner, subobject_name
)
select st.owner,
st.object_name,
st.subobject_name,
(st.pr-st.prd) cached_physical_reads,
ds.bytes/power(1024,2) mb
from dba_segments ds, segstat st
where ds.owner=st.owner
and ds.segment_name=st.object_name
and ds.segment_type=st.object_type
and nvl(ds.partition_name, ds.segment_name)=nvl(st.subobject_name, st.object_name)
and ds.buffer_pool='DEFAULT'
order by st.pr-st.prd desc
)
where rownum < 21;
This query will identify the top 20 segments, currently in the default buffer pool, that have the highest physical reads. Now, it will also print the size of the object.
So, first, determine how much of your system's memory you can afford to allocate to the recycle and keep pools. Size the two new pools accordingly. Second, look at the output of the above script, and, for each segment, look at the size. Is is small enough to be cached entirely? If so, assign it to the keep pool. If it's way too large to cache entirely, assign it to the recycle pool.
You'll certainly overallocate the recycle pool, in terms of total object size vs. size of recycle pool. That's sort of the point for the recycle pool, damage limitation.
In the case of the keep pool, depending on the sizes of the objects, try to keep within the bounds of the keep pool size. You may overallocate slightly, but try not to overallocate grossly, like you're bound to do with the recycle pool. The idea here is to isolate small, heavily used objects that can be cached entirely, and eliminate any further reads on them.
As I said, no hard and fast rules, cause every system is different, but, with the above script, the ideas here, and some idea of how your application works, you should be able to make a lot of progress.
-Mark
|
|
|
Posts:
75
Registered:
03/17/00
|
|
|
|
Re: Multiple Buffer
Posted:
Jun 26, 2007 10:56 PM
in response to: burleson
|
|
|
|
Thank you very much!
Is it any perticular measurement - Query to find following? I have Oracle 9i on Sun Solaris and it's about 50 GB DB with around 1000 tables and 1400 indexes.
Currently we have only DEFAULT buffer pool
1 .Tables (and associated indexes) that are small and have frequent full-table scans
2. Objects that have more than 80% of their data blocks in the buffer
Thanks,
|
|
|
Posts:
75
Registered:
03/17/00
|
|
|
|
Re: Multiple Buffer
Posted:
Jun 26, 2007 11:02 PM
in response to: Mark J. Bobak
|
|
|
|
Thanks Mark for your script and explaination.
I will run this query and let you know.
Thanks once again!
|
|
|
Posts:
75
Registered:
03/17/00
|
|
|
|
Re: Multiple Buffer
Posted:
Jun 27, 2007 3:39 PM
in response to: pdshah
|
|
|
|
Mark,
Thanks for your earlier response. I was able to run your query and found following results. Do I need to restrict to <= 21?
OWNER OBJECT_NAME CACHED_PHYSICAL_READS MB
ora C_U_ATTR 2648793092 58.875
ora C_SURV_RESP 2569957476 216
ora HRT_APPL 1255885098 320.375
ora HR_VW_NOTE 1217831147 86
ora C_U_GRP 265876430 529.75
ora B2B_ITM_LST 251173927 44.625
ora EMP_INFO 140302432 22.125
ora C_RCV_INFO 127806535 735.125
ora DPS_FOLD 110500120 19.5
ora HRT_POST 105302622 10.5
ora SRV_RESP 100484931 36
ora C_U_GRP_ATTR 91382000 47.25
ora DC_MED_TXT 91158559 19
ora CUST_SALESEMP 84850852 66.75
ora D_ROL 84500634 141.875
ora D_USR 72096368 64
ora VR_PO_ITM 47788125 9094
ora CL_PRD_REG 47732518 34.875
ora PG_ATTR 41482518 38.875
ora CUST_DIV 28137692 25
What I should consider form here?
Thanks,
|
|
|
Posts:
75
Registered:
03/17/00
|
|
|
|
Re: Multiple Buffer
Posted:
Jun 29, 2007 7:05 AM
in response to: pdshah
|
|
|
|
I am still confused to make proper determination to create KEEP or RECYCLE buffer pool? Could someone guide me? Whatever I have mentioned query in my first question and Mark has suggested - query, which one is the best measurement?
I just need to confirm which parameter needs to be considered after running those queries?
Thanks and appreciated your response!
|
|
|
Posts:
1,911
Registered:
01/23/07
|
|
|
|
Re: Multiple Buffer
Posted:
Jun 29, 2007 8:25 AM
in response to: pdshah
|
|
|
pdshah,
You will rarely be able to beat Oracle's caching algorithms by playing with KEEP and RECYCLE pools - but there are a few special cases.
Case 1: there is a bug in 8i and 9i which means that Oracle does not increment the touch count on blocks that have been loaded into the cache by tablescan. "Short" tables (less than 2% of the size of the buffer cache) are supposed to be loaded to the mid-point of the cache and follow the normal touch-count and aging process, but because of the touch count bug they can fall off the end of the buffer very quickly. If you do frequent scans of short tables, then consider creating a KEEP pool large enough - with a little spare - to hold them. Better still, find out why you are doing lots of tablescans and see if you need to stop it happening, as such tablescans waste CPU.
Case 2: you have a very large object that is accessed so randomly that if you read a block from it now, you are unlikely to want that block again for ages. So there's no point in caching it. But every time you read a block from it, you have to kick something else out of the cache. You could consider creating a relatively small RECYCLE cache and allocating that object to it. This requires you to know your application - check v$segstat (or v$segment_statistics) for any objects which suffer a lot of single block reads, and ask yourself how much worse the reads would get if you pushed it into a RECYCLE cache - compare physical with logical i/os for the object, the difference is roughly the volume of extra reads.
Case 3: You have a large object (usually an index) which is just a bit too big to survive in memory even though every block is frequently accessed. Consider creating a KEEP pool for this object. You probably won't get a win from this strategy - you're trying to be Oracle's years of experience with caching algorithms - but you might get lucky. Again, though, you have to know your application.
Of these, the second (RECYCLE pool) is the case where you are most likely to gain some benefit.
Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com
http://www.jlcomp.demon.co.uk
|
|
|
Posts:
75
Registered:
03/17/00
|
|
|
|
Re: Multiple Buffer
Posted:
Jun 29, 2007 12:45 PM
in response to: Jonathan Lewis
|
|
|
|
Thank you very much Jonathan.
I really appreciate your detail explanation.
So you are telling me that i should run only with my DEFAULT pool as it is and donot create any KEEP POOL or RECYCLE pool?
Did you see the queries i am running in my first email? Then which field/value i should really consider?
I am getting hit ratio for DEFAULT is negative in production (like -27.43, -102.63, -88.63, 8.07, -11.36, -38.4, -265.04, -147) but in staging I have around 91, 93.
running following query:
SELECT NAME, 100 - round ((PHYSICAL_READS / (DB_BLOCK_GETS + CONSISTENT_GETS))*100,2) HitRatio
FROM V$BUFFER_POOL_STATISTICS;
Thanks,
|
|
|
Posts:
534
Registered:
09/10/98
|
|
|
|
Re: Multiple Buffer
Posted:
Jun 29, 2007 2:08 PM
in response to: pdshah
|
|
|
Well, I have to respectfully disagree with Jonathan. I've had excellent results from implementing a KEEP and RECYCLE pool.
As far as specific steps, you need to read what I wrote here http://forums.oracle.com/forums/message.jspa?messageID=1919339#1919339 in my previous reply. Particularly, the comments/questions about how large is the current buffer cache? ow much memory is available on the system to allocate to keep and recycle? Once you have those, you can start going through the results of the query, to determine which objects are KEEP or RECYCLE candidates.
|
|
|
Posts:
75
Registered:
03/17/00
|
|
|
|
Re: Multiple Buffer
Posted:
Jun 29, 2007 4:01 PM
in response to: Mark J. Bobak
|
|
|
|
Hi Mark,
Once again Thanks for your kind response. Now My question is when I ran this query, I got following results. How can I know that which objects will be candidates for KEEP and Recycle? I am puzzling myself for KEEP and Recycle candidates?
OWNER OBJECT_NAME CACHED_PHYSICAL_READS MB
ora C_U_ATTR 2648793092 58.875
ora C_SURV_RESP 2569957476 216
ora HRT_APPL 1255885098 320.375
ora HR_VW_NOTE 1217831147 86
ora B2B_ITM_LST 251173927 44.625
ora EMP_INFO 140302432 22.125
ora C_RCV_INFO 127806535 735.125
ora DPS_FOLD 110500120 19.5
ora HRT_POST 105302622 10.5
ora SRV_RESP 100484931 36
ora C_U_GRP_ATTR 91382000 47.25
ora DC_MED_TXT 91158559 19
ora CUST_SALESEMP 84850852 66.75
ora D_ROL 84500634 141.875
ora D_USR 72096368 64
ora VR_PO_ITM 47788125 9094
ora CL_PRD_REG 47732518 34.875
ora PG_ATTR 41482518 38.875
ora CUST_DIV 28137692 25
Thanks,
|
|
|
Posts:
1,911
Registered:
01/23/07
|
|
|
|
Re: Multiple Buffer
Posted:
Jun 29, 2007 11:50 PM
in response to: Mark J. Bobak
|
|
|
Mark, I have no problem with you disagreeing with me. However it looks like the disagreement is only on a matter of frequency.
I agree entirely with your approach of analysing v$segment_statistics (although I prefer to use v$segstat as it is slightly less aggressive) to estimate the benefit of playing with the KEEP and RECYCLE pools.
The only thing I would suggest is the need to pick up the logical reads at the same time so that you can get an idea of (a) how many logical reads might become physical if you put something in the RECYCLE pool, and (b) what percentage of reads you are avoiding if you put something in the KEEP pool - as this may give you an idea of the benefit that might become apparent to the users.
My main reason for being pessimistic about the KEEP pool, in particular, is that if you have a fixed amount of memory then any that you assign to the keep pool may limit Oracle's ability to handle objects which have variable caching requirements through the daily working cycle.
If you create both a KEEP and a RECYCLE pool, by the way, you should keep an eye open for "free buffer waits" - see http://jonathanlewis.wordpress.com/2006/11/21/free-buffer-waits/ that can indicate a need to increase the size of the RECYCLE pool.
Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com
http://www.jlcomp.demon.co.uk
|
|
|
Posts:
1,911
Registered:
01/23/07
|
|
|
|
Re: Multiple Buffer
Posted:
Jun 30, 2007 12:03 AM
in response to: pdshah
|
|
|
pdshah
The first three queries are joining on the wrong column, and omit analysis of subpartitions. One of them tests for status = 'free' , which is a predicate to use against v$bh - the relevant column in x$bh is called state and is a numeric.
None of the queries considers the possibility of multiple CR copies of a single block in the buffer cache, which is probably an important consideration for trying to set the best sizes for both the KEEP and RECYCLE (see my reply to Mark Bobak for the dependency).
I don't think I've ever bothered to write a query to calculate a cache hit ratio - but the fact that you've managed to get negative values from a piece of code that is probably supposed to return values between 0 and 100 shows that the code is wrong: or at least inappropriate for your version of Oracle. (I note, for example, that it doesn't consider direct path reads - and I am aware that v$buffer_pool_statistics was far from consistent with v$sysstat in some versions of Oracle anyway).
Forget the silly scripts to check buffer usage and hit ratios. The accumulation in v$segstat (as shown by Mark Bobak) is far more important. The only interesting test is: how much I/O is a specific segment subject to, and how much would that (probably) change if you used a different cache for that object.
Even then you can be fooled because a read that is reported as a physical read may be coming out of a filesystem or disk cache somewhere and operate at a speed that makes it pointless to sacrifice cache that could be used to greater benefit by another object.
The difficulty is that setting aside memory for specific caches reduces the size of the default cache - which changes the caching strategy for all other objects; and the side-effects may outweigh the direct benefits. Hence my bias in favour of RECYCLE pools which tend to be "small" and against KEEP pools which tend to be "large" (except for the ones used to address the tablescan bug).
The measure of I/O from v$segstat is a guideline to help you find objects that are worth considering - but ultimately you need to understand the application to be confident that it's worth making the change.
Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com
http://www.jlcomp.demon.co.uk
|
|
|
Posts:
2,343
Registered:
05/06/98
|
|
|
|
Re: Multiple Buffer
Posted:
Jun 30, 2007 4:56 AM
in response to: pdshah
|
|
|
Hi,
How can I know that which objects will be candidates for KEEP
Everybody uses slightly different rules. According to Oracle documentation, we see:
“A good candidate for a segment to put into the KEEP pool is a segment that is smaller than 10% of the size of the DEFAULT buffer pool and has incurred at least 1% of the total I/Os in the system”.
More concisely, a small table that is in high demand is a good candidate for KEEP caching.
Internally, it is critical to cache small-table full-table scans because the Oracle data buffer does not increase the touch count when blocks from full-table scans are referenced.
Hence, small-table full-table scan blocks will age-out of the data buffers very quickly, causing unnecessary disk I/O. I believe that this is causing you additional disk I/O that could be easily avoided.
I have some more details here:
http://www.dba-oracle.com/t_script_automate_keep_pool_tables_indexes.htm
Hope this helps. . .
Donald K. Burleson
Oracle Press author
|
|
|
|
Legend
|
|
Guru : 2500
- 1000000
pts
|
|
Expert : 1000
- 2499
pts
|
|
Pro : 500
- 999
pts
|
|
Journeyman : 200
- 499
pts
|
|
Newbie : 0
- 199
pts
|
|
Oracle ACE Director
|
|
Oracle ACE Member
|
|
Oracle Employee ACE
|
|
Helpful Answer
(5 pts)
|
|
Correct Answer
(10 pts)
|
|