Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > Oracle Database

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-24-2008, 01:09 PM
RogBaker@gmail.com
 
Posts: n/a
Default 2 Buffer Cache Questions

1. If you select * from a table, shouldn't that load the whole table
into the database buffer cache, provided it fits. I have a script that
I found that shows me what's in the cache, but I cannot seem to make
100% of a tables block fit. I could not seem to find the answer in the
concepts manual.

2. What's does system put in the buffer cache. We notice that after
starting the db, system will occupy a good chunk of the buffer cache,
but that will start to decrease as various queries are run and the data
begins to fill the cache.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-24-2008, 01:09 PM
Joel Garry
 
Posts: n/a
Default Re: 2 Buffer Cache Questions


RogBa...@gmail.com wrote:
> 1. If you select * from a table, shouldn't that load the whole table
> into the database buffer cache, provided it fits. I have a script

that
> I found that shows me what's in the cache, but I cannot seem to make
> 100% of a tables block fit. I could not seem to find the answer in

the
> concepts manual.


Look up keep and recycle.
http://download-west.oracle.com/docs...emor.htm#11256

>
> 2. What's does system put in the buffer cache. We notice that after
> starting the db, system will occupy a good chunk of the buffer cache,
> but that will start to decrease as various queries are run and the

data
> begins to fill the cache.


I thought you said you had a script?

Maybe you should show us the script. Oracle does a lot of stuff in the
SGA, and unless you are halting the system and looking at all the bytes
in memory, I have difficulty believing any script can create a cohesive
and correct snapshot. Even Oracle doesn't know, google discussions of
delayed block cleanout for an extreme case, but generally for anything
you do, Oracle has to figure out if the necessary blocks are in memory,
and if they are part of your transactional view or if Oracle has to fix
them to look right. Whether it is a good thing to cache or keep an
entire table... depends.

It also helps to post basic informational context:
http://www.dbaoracle.net/readme-cdos.htm

jg
--
@home.com is bogus.
Or, as Tom would say, Why?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-24-2008, 01:09 PM
DA Morgan
 
Posts: n/a
Default Re: 2 Buffer Cache Questions

RogBaker@gmail.com wrote:
> 1. If you select * from a table, shouldn't that load the whole table
> into the database buffer cache, provided it fits. I have a script that
> I found that shows me what's in the cache ....


Please post the script ... I have my doubts too.
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace 'x' with 'u' to respond)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-24-2008, 01:10 PM
RogBaker@gmail.com
 
Posts: n/a
Default Re: 2 Buffer Cache Questions

I have a script, which ecludes SYSTEM and SYS objects. A Co-worker is
running a tool from the Enterprise Manager performance pack or
something that is showing graphs of what's in the Buffer Cache, and it
was showing a lot of SYSTEM objects initally after the database is
started. I suppose I could have edited the script I was using to
include SYS and SYSTEM.

I analyzed the scripts, and the bases for them are dba_objects.blocks
and the number of rows returned from v$bh.
Just ignoring the scripts and looking at dba_objects and v$bh, I get 29
blocks total from v$bh, and 32 blocks from dba_objects.
That gives me the same percentage of the scripts (91% for this example
table). Anyway, the scripts are below for your review.

Whenever I use a script that I find on the internet, I try to verify it
with something I found somewhere else.
Here is the script I used, it's from
http://www.pafumi.net/multi_buffers.htm
--------------------------------------------
set pages 999
set lines 92

ttitle 'Contents of Data Buffers'

drop table t1;

create table t1 as
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
order by count(distinct file# || block#) desc;

column c0 heading "Owner" format a12
column c1 heading "Object|Name" format a20
column c2 heading "Object|Type" format a7
column c3 heading "Number of|Blocks in|Buffer|Cache" format
99,999,999
column c4 heading "% of |object|blocks |in Buffer" format 999
column c5 heading "Buffer|Pool" format a7
column c6 heading "Block|Size" format 99,999

select t1.owner c0,
object_name c1,
case when object_type = 'TABLE PARTITION' then 'TAB PART'
when object_type = 'INDEX PARTITION' then 'IDX PART'
else object_type end c2,
sum(num_blocks) c3,
(sum(num_blocks)/greatest(sum(blocks), .001))*100 c4,
buffer_pool c5,
sum(bytes)/sum(blocks) c6
from 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;

drop table t1;
---------------------------------------

I found another version that had just about the same results from
"everybody's favorite DBA:"
http://www.dba-oracle.com/art_builder_buffer.htm
----------------------
set pages 999
set lines 80

spool blocks.lst

ttitle 'Contents of Data Buffers'

drop table t1;

create table t1 as
select
o.object_name object_name,
o.object_type object_type,
count(1) num_blocks
from
dba_objects o,
v$bh bh
where
o.object_id = bh.objd
and
o.owner not in ('SYS','SYSTEM')
group by
o.object_name,
o.object_type
order by
count(1) desc
;


column c1 heading "Object|Name" format a30
column c2 heading "Object|Type" format a12
column c3 heading "Number of|Blocks" format 999,999,999,999
column c4 heading "Percentage|of object|data blocks|in Buffer" format
999

select
object_name c1,
object_type c2,
num_blocks c3,
(num_blocks/decode(sum(blocks), 0, .001, sum(blocks)))*100 c4
from
t1,
dba_segments s
where
s.segment_name = t1.object_name
and
num_blocks > 10
group by
object_name,
object_type,
num_blocks
order by
num_blocks desc
;
-------------------------------

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-24-2008, 01:10 PM
Richard Foote
 
Posts: n/a
Default Re: 2 Buffer Cache Questions

"DA Morgan" <damorgan@x.washington.edu> wrote in message
news:1115160207.398912@yasure...
> RogBaker@gmail.com wrote:
>> 1. If you select * from a table, shouldn't that load the whole table
>> into the database buffer cache, provided it fits. I have a script that
>> I found that shows me what's in the cache ....

>
> Please post the script ... I have my doubts too.
> --


The point that's been missed is that if the table being selected is large
(greater than 2% of buffer cache), a full table scan will load blocks
directly into the cold or least recently used end of the buffer cache LRU
list resulting in it's blocks being subsequently overwritten during the
scan. Therefore, *no*, the whole table wouldn't be expected to be found in
the buffer cache, even if it's size is less than the buffer cache.

Thankfully it's expected and desirable behaviour else FTS of large tables
will have the undesirable effect of potentially forcing more useful blocks
out of cache. This mechanism is somewhat version dependent.

Of course, if the FTS is performed in parallel, then direct reads into the
PGA are performed, bypassing the buffer cache entirely.

Cheers

Richard


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-24-2008, 01:10 PM
RogBaker@gmail.com
 
Posts: n/a
Default Re: 2 Buffer Cache Questions

I don't know if size is the problem. I am using Oracle 9.2
I am the only user in the db. (I did have to make the cache pretty
small by the way). I have 2 tables that I am playing with:
HARITEMS and HARPKGHISTORY. They both are quite small.

According to Oracle, they both have the same number of blocks:
SQL> select segment_name, blocks from dba_segments where segment_name
in ('HARITEMS','HARPKGHISTORY');

SEGMENT_NAME BLOCKS
-------------- ----------
HARITEMS 8
HARPKGHISTORY 8

TOAD tells me that
HARITEMS has 7 Blocks, 0 Empty Blocks
HARPKGHISTORY has 1 Blocks, 6 Empty Blocks

yet when I run the aforementioned scripts after select * from either
table, it will only tell me that 100% of HARITEMS is in the Buffer
Cache.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-24-2008, 01:10 PM
bdbafh@gmail.com
 
Posts: n/a
Default Re: 2 Buffer Cache Questions

After reading your post and replies, I still cannot determine what
problem you are attempting to solve, other than a possible
misunderstanding or misconception.
Perhaps some time spent in the concepts manual and other documentation
available online is your best bet.

-bdbafh

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-24-2008, 01:10 PM
xhoster@gmail.com
 
Posts: n/a
Default Re: 2 Buffer Cache Questions

RogBaker@gmail.com wrote:
> 1. If you select * from a table, shouldn't that load the whole table
> into the database buffer cache, provided it fits.


No, unless the table is small.

> I have a script that
> I found that shows me what's in the cache, but I cannot seem to make
> 100% of a tables block fit.


Why are you trying to make that happen?

> I could not seem to find the answer in the
> concepts manual.
>
> 2. What's does system put in the buffer cache.


Whatever it needs to. System stuff.

> We notice that after
> starting the db, system will occupy a good chunk of the buffer cache,


What you notice is that after starting the db, the system will occupy a
good chunk of the *occupied portion* of the buffer cache. And of course
it does. What else would be occupying the buffer cache immediately
after a clean restart? Most of it is unused, and the part that is used
is used for system stuff.

> but that will start to decrease as various queries are run and the data
> begins to fill the cache.


Yes, of course.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 02-24-2008, 01:10 PM
RogBaker@gmail.com
 
Posts: n/a
Default Re: 2 Buffer Cache Questions

I do not have a problem, I am just trying to understand something
better.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 02-24-2008, 01:11 PM
Mladen Gogala
 
Posts: n/a
Default Re: 2 Buffer Cache Questions

On Wed, 04 May 2005 10:28:40 -0700, RogBaker wrote:

> I do not have a problem, I am just trying to understand something
> better.


Take a peek at the contents of the buffer pool. One way of doing it would
be to take a look at V$BH or V$CACHE. That would be the best way to learn,
PFY.

--
Egoist: A person of low taste, more interested in themselves than in me.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:20 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655