Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: how does oracle store cursors in memory?
Ryan, I am attaching a better buffer cache diagram (I
hope). Except under certain full table scan conditions
Datablocks are not stored in the PGA. Everything is
done via the shared_pool and SGA through pointers.
If you select address from v$sqlarea this gives you
the handle address of the object in the library cache.
The theory is that if your application executes a sql
statement it should generate a hash and that address
may or may not already exists in the shared pool if it
does not then your process should generate an
execution plan and load the dictionary objects into
the “dc” area of the shared pool and your PGA will now
have a pointer to that address. If the address already
exists then your pga will establish a pointer to the
already existing SQL (execution plans and other
necessities). Your PGA will also keep certain status
information about the status of the cursor as well as
pointers to sort segment handles. The bottom line is
that the PGA is usually a series of pointers to the
SGA.
Without source code you have to make some assumptions
but you can figure a lot this out using the oradebug
command and the GNU debugger (gdb) to dump the
processes and use gdb to dig into the structures of
the PGA.
Have fun. I remember when I like to do this kinda stuff. Now I am just happy I can get Oracle to install, run and not have any bugs.
Scott
Buffer Cache Overview: ~~~~~~~~~~~~~~~~~~~~~~ This example applies toOracle7 and Oracle8, although in reality there may be multiple LRU chains. InOracle8i the LRU concept is replaced by a touch-count algorithm but the idea is the same. LRU Chain: Most Recent Doubly linked list Least Recent
+------+------+------+ - - - - +------+------+------+------+------+ | | | | || PTR | | | | +------+------+------+ - - - - +------+------+------+------+------+ Newly used buffers | We search for areplaced at this end. | LRU just FREE buffers | points from this end LRUW Chain(Dirty List): | to of the LRU. +------+------+ - - +------+ | buffer Dirty buffers | | | | | | headers. are moved to +------+------+ - - +------+ | LRUW if there (Cleared by DBWR) | is room. | | Hashing is | based on DBA | modulo the | number of buckets. | A LATCH protects | each hash chain | |
,-------. --------------------------------/----------------------+ Double | Hash | <------------------------------/---------------------+ | linked |Bucket| ,--------. ,---------V----. ,--------. | | hash | 1 | ----->| Buffer |--->| Buffer |---->| Buffer |--+ | chain. `-------' <-----| Header |<---| Header |<----| Header |<---+ | 40 | | 2 | | 999 | | | | | | | |--------| | |
| | |Usr|Wait| | | | | `--------' `--------------' `--------' ,-------. | | |: |SO. |--------------' | | | | | | `-------' | | Buffer Handle | | state object | | | | (actual DB blocks) | | ,-------------------. ,-------. | | | 1| | Hash | | | | | | Bucket| | | +-------------------+ | 2 | -->... | `---------->| 2 | `-------' <--... | | | | +-------------------+ | : : | +-------------------+ : `-------------------------->| 40 Data Block | : | | +-------------------+ : : +-------------------+ ,-------. | 999 | | Hash | | | | Bucket| +-------------------+ | N | | 1000 | `-------' | | There are a PRIME +-------------------+ number of Hash buckets. ----------------------------------------------------------------Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- Archives are at http://www.freelists.org/archives/oracle-l/ FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html -----------------------------------------------------------------Received on Fri Feb 13 2004 - 22:57:25 CST
![]() |
![]() |