Find available space in buffer cache

Hi.
I want to find available space from buffer cache. First thought was to make it 8i-9i comp, by not using v$bh to calculate sum of memory and available space.
I have the following pl/sql block to calculate the values:
declare
num_free_blck integer;
num_all_blck integer;
num_used_blck integer;
overal_cache number := 0;
used_cache number := 0;
free_cache number := 0;
blck_size integer;
pct_free number := 0;
begin
select count(1) into num_free_blck from v$bh where status='free';
select count(1) into num_all_blck from v$bh;
select count(1) into num_used_blck from v$bh where status <> 'free';
select value into blck_size from v$parameter where name ='db_block_size';
used_cache := (blck_size * num_used_blck)/(1024*1024);
free_cache := (blck_size * num_free_blck)/(1024*1024);
overal_cache := (blck_size * num_all_blck)/(1024*1024);
pct_free := ((free_cache/overal_cache)*100);
dbms_output.put_line('There are '||num_free_blck||' free blocks in buffer cache');
dbms_output.put_line('There are '||num_used_blck||' used block in buffer cache');
dbms_output.put_line('There are totally '||num_all_blck||' blocks in buffer cache');
dbms_output.put_line('Overall cache size is '||to_char(overal_cache,'999.9')|| 'mb');
dbms_output.put_line('Used cache is '||to_char(used_cache,'999.9')||' mb');
dbms_output.put_line('Free cache is '||to_char(free_cache,'999.9')||' mb');
dbms_output.put_line('Percent free db_cache is '||to_char(pct_free,'99.9')||' %');
end;
The result of the execution is:
SQL> @c:\temp\bh
There are 3819 free blocks in buffer cache
There are 4189 used block in buffer cache
There are totally 8008 blocks in buffer cache
Overall cache size is 62.6mb
Used cache is 32.7 mb
Free cache is 29.8 mb
Percent free db_cache is 47.7 %
PL/SQL-prosedyren ble fullført.
SQL>
This is not correct according to the actuall size of the buffer cache:
SQL> select name,value from v$parameter where name='db_cache_size';
NAME
VALUE
db_cache_size
67108864
SQL>
Anyone that have an idea bout this?
Thanks
Kjell Ove

Mark D Powell wrote:
select decode(state,0,'Free',
1,'Read and Modified',
2,'Read and Not Modified',
3,'Currently being Modified',
'Other'
) buffer_state,
count(*)  buffer_count
from    sys.xx_bh
group by decode(state,0,'Free',
1,'Read and Modified',
2,'Read and Not Modified',
3,'Currently being Modified',
'Other'
Provided the OP figures out that xx_bh is probably a view defined by sys on top of x$bh this will get him the number of free buffers - which may be what he wants - but apart from that your query is at least 10 years short of complete, and the decode() of state 3 is definitley wrong.
The decode of x$bh.state for 10g is:
     decode(state,
          0,'free',
          1,'xcur',
          2,'scur',
          3,'cr',
          4,'read',
          5,'mrec',
          6,'irec',
          7,'write',
          8,'pi',
          9,'memory',
          10,'mwrite',
          11,'donated'
     ), and for 11g it is:
     decode(state,
           0, 'free',
           1, 'xcur',
           2, 'scur',
           3, 'cr',
           4, 'read',
           5, 'mrec',
           6, 'irec',
           7, 'write',
           8, 'pi',
           9, 'memory',
          10, 'mwrite',
          11, 'donated',
          12, 'protected', 
          13, 'securefile',
          14, 'siop',
          15, 'recckpt',
          16, 'flashfree', 
          17, 'flashcur',
          18, 'flashna'
     ), (At least, that was the last time I looked - they may have changed again in 10.2.0.5 and 11.2.0.2)
Regards
Jonathan Lewis

Similar Messages

  • Available blocks in buffer cache

    Hi.
    I need to find available blocks in buffer cache. I can not query x$bh as not sysdba user. Anyone that has an idea how to get this information. I tried query the v$bh view but I can not get it right.
    Anyone with a good idea?
    Rgds
    Kjell OVe

    No,
    When you have a 100m buffer cache, it means you can buffer 100m/8k blocks of your database in cache, and you don't need to read them from disk.
    When the cache gets full Oracle will use a modified Least Recently Used algorithm to determine which blocks can be flushed.
    If the block is unmodified (not dirty) it will simply be removed, if it is modified it will be written to disk.
    When you insert a record (you seem to be really obsessed by this)
    - Oracle will look for free space in the current segment.
    When it finds a block and it is not in cache, it will retrieve this in cache.
    - if there is no space, Oracle will allocate a new extent.
    It will retrieve blocks from the new extent in cache. Simply: each block in the cache has a RBA (relative block address). The RBA points to a block on disk.
    - When it can't allocate an extent, Oracle will try to extend the tablespace (actually the datafile)
    If this doesn't succeed Oracle will raise an error, and send the error number and error text to the client program.
    The failing statement will be rolled back automatically.
    Hth
    Sybrand Bakker
    Senior Oracle DBA

  • Finding used space in Oracle Cache

    Is there any way to find the size of the buffer cache used to perform a particular query. I want it in exact bytes/blocks. I doesnot mean the maximum buffer cache, but the used buffer cache?

    Hi;
    What is db version?
    please see below thread which could you give some hint to you
    buffer cache usage
    Buffer Cache Usage
    Regard
    Helios

  • Find free buffers in buffer cache

    hi guys,
    V$BH view contains the information about each block that is present in the buffer cache. can any one please tell me how to find the information about the free buffers??

    Mark D Powell wrote:
    select decode(state,0,'Free',
    1,'Read and Modified',
    2,'Read and Not Modified',
    3,'Currently being Modified',
    'Other'
    ) buffer_state,
    count(*)  buffer_count
    from    sys.xx_bh
    group by decode(state,0,'Free',
    1,'Read and Modified',
    2,'Read and Not Modified',
    3,'Currently being Modified',
    'Other'
    Provided the OP figures out that xx_bh is probably a view defined by sys on top of x$bh this will get him the number of free buffers - which may be what he wants - but apart from that your query is at least 10 years short of complete, and the decode() of state 3 is definitley wrong.
    The decode of x$bh.state for 10g is:
         decode(state,
              0,'free',
              1,'xcur',
              2,'scur',
              3,'cr',
              4,'read',
              5,'mrec',
              6,'irec',
              7,'write',
              8,'pi',
              9,'memory',
              10,'mwrite',
              11,'donated'
         ), and for 11g it is:
         decode(state,
               0, 'free',
               1, 'xcur',
               2, 'scur',
               3, 'cr',
               4, 'read',
               5, 'mrec',
               6, 'irec',
               7, 'write',
               8, 'pi',
               9, 'memory',
              10, 'mwrite',
              11, 'donated',
              12, 'protected', 
              13, 'securefile',
              14, 'siop',
              15, 'recckpt',
              16, 'flashfree', 
              17, 'flashcur',
              18, 'flashna'
         ), (At least, that was the last time I looked - they may have changed again in 10.2.0.5 and 11.2.0.2)
    Regards
    Jonathan Lewis

  • Issue while finding disk space using df -k . , df -g . & statvfs API

    Hi,
    To find disk space:
    If I use df -k . command to find available space, it gives
    6927549 available space
    Where as if I use df -g . command it gives
    13855098 avaliable space which is exactly double of above (6927549 * 2) available space.
    Also, I have used statvfs API to get free disk space and it is giving as,
    f_bavail= 6927493 ----- which is equivalent to df -k . command's disk space.
    f_bsize = 8192
    f_frsize= 1024
    f_blocks= 140918146
    f_bfree= 8336674
    f_files= 16959488
    f_ffree= 16325903
    f_fsid= 8388630
    f_basetype= ufs
    f_flag= 4
    f_namemax= 255
    So, my question is why it is getting doubled when I use df -g for current file system?

    Because df -g reports in 512 bytes blocks not in Kilobytes.
    You'll notice the man page says that specifying the -g option overrides the -k (report in Kb) option.
    Unfortunately for historical reasons all the internal interfaces like statvfs report things in blocks.

  • AWR's buffer cache reads and logical reads

    In AWR report under "Segments by Logical Reads" section, there is a total logical reads, I assume it is in unit of block. Under "IOStat by Function summary" section, it has buffer cache reads in unit of bytes. Shouldn't the number of logical reads x 8k (if the block size is 8k) = the number of buffer cache reads?
    They are not equal, not even close, does anybody know why? Thanks

    Hi,
    buffer gets = number of times a block was requested from buffer cache. A buffer get always request in a logical read. Depending on whether or not a copy of the block is available in the buffer cache, a logical read may or may not involve a physical read. So "buffer gets" and "logical reads" are basically synonyms and are often used interchangeably.
    Oracle doesn't have a special "undo buffer". Undo blocks are stored in rollback segments in UNDO tablespace, and are managed in the same way data blocks are (they're even protected by redo). If a consistent get requires reading from UNDO tablespace, then statistics counters will show that, i.e. there will be one more consistent get in your autotrace.
    For more information and some examples, see a thread at askTom:
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:549546900346542976
    Best regards,
    Nikolay

  • Which objects are in buffer cache? How much space is each taking up?

    Hi All,
    I am on Oracle v 11.2.0.2 (64 bit) RedHat.
    I want to find out which objects have presence in buffer cache? and how much space each object is taking up in buffer cache?
    I googled around and found few queries based on view x$bh. But when tried to run those on my database, I cannot find x$bh (the user has SELECT_CATALOG_ROLE privilege). Is there any other view holding same information as x$bh?
    Thanks in advance.

    Be careful, there is quite a bit of misinformation floating about the net about querying v$bh. What exactly do you want to know, that is, what do you want a user to do with the information?
    Edit: Oh, you said x... Why the x$bh view does not exist?
    Edited by: jgarry on May 16, 2012 2:58 PM

  • Verbatim disk drive historically used only for time machine backups. Recently i added some other media files to use some of available space without partitioning, the disc now refuses to mount in finder despite appearing in disk utility. Repair fails. HELP

    Sorry to elaborate a bit more.
    I have used time machine since owning my mac book pro with no issues. i keep the timemachine backups on an external hard drive made by Verbatim. This has not external power source.
    Recently i decided to use up some of the available space on the external verbatim disk drive to store some movie files which were sitting on my macbook pro.
    Therefore i created a new folder outside of the time machine backup folder and stored the movie files in there.
    From then on Time machine failed... and a few days later i noticed it was not mounting in 'finder'
    Therefore i used disk utility to see if it was recognising it. Which i was. However when i try to repair it the repair process fails.
    In disk utility i am presented with 1 TB Samsung HN M10 which has a child called Verbatim HD.
    The 1TB Samsung hardware appears fine, but the verbatim disk i am unable to fully verify and fix.
    Does this mean i have lost all my back ups?
    Have I lost all the media that i put on there?
    Is there any way to fix this?
    Any help would be appreciated.
    didier07...

    To summarize: You used an external Verbatim HD for your TM backups. Then, you stored some movie files on the "spare" space on the Verbatim drive. Now, Disk Utility isn't being recognized, and repair is disabled. Your home Samsung drive is working fine, but the Verbatim cannot be verified.
    The problem, I believe, is that the external Verbatim drive wasn't partitioned. There should be two partitions: one for TM backups, the other for video. That way, you can perform backups, and still retain some space for video or somesuch.
    Frankly, I don't know how to fix this except through the following. (1) Erase the Verbatim drive, (2) Create a new blank space and format it, (3) Make two partitions - one for backup, the other for video. (4) Run TM through one partition, but switch to the other for your videos.  The better solution might be to have one dedicated drive (perhaps the Verbatim) for backups, and another dedicated drive for video backups; that way, you'll have plenty of space for expansion.
    I hope someone will correct me if I'm incorrect, but I believe you've essentially lost your backups and media. I don't know how you can retrieve that clump of the now-undifferentiated data on the Verbatim drive. To retrieve any lost data, you're going to require another external drive that's larger in capacity, as well as data recovery software; don't expect encouraging results. If you're desperate, there are firms like Drive Savers that can offer a more comprehensive solution - at a cost.
    Post if you have questions, or additional concerns!

  • " unable to allocate space from the buffer cache" Message

    Hi
    I am trying to delete a large volume or records from a BTREE database. I have used the DB_SET_RANGE with a cursor to locate the desired records. After that the Dbc::get() with DB_NEXT is called. After deleting a considerable amount of records I am receiving a message in the error callback function as "unable to allocate space from the buffer cache".
    What might be the reason for such a message.
    Regards
    Nisam

    Nisam,
    This means that the cache is full and there are no pages that BDB can evict to make space. Are you running with the default cache size? You can increase the cache size by calling: dbenv->set_cachesize or db->set_cachesize.
    Related docs:
    Selecting a cache size: http://www.oracle.com/technology/documentation/berkeley-db/db/ref/am_conf/cachesize.html
    Bogdan Coman

  • How to see available space in a blank dvd when burning in finder? It no longer display at the bottom of the finder window.

    How to see available space in a blank dvd when adding files in finder? It no longer displays at the bottom of the finder window.

    Choose Show Status Bar from the View menu.
    (113198)

  • HT4878 Can the available space statistic in Finder be corrected to reflect the "true" available space, as shown in Disk Utility?

    Would appreciate a solution, as this discrepancy is uncomfortable ans doesn't sound like something terryibly difficult to solve.

    Since the Local Snapshots are "expendable" -- they'll be deleted automatically if your disk gets over 80% full -- the difference really isn't a problem (once you know what it is!).
    Thus, for most purposes, the "true" available space on Finder is actually more acccurate than Disk Utility.
    To see what's really going on, use the "Storage" display, as it breaks the Local Snapshots out separately (but labels them "Backups").

  • Error running maverick upgrade: You need 4.93 GB of available space to download OS X Mavericks. Remove items from your startup disk to increase available space. where do i find the startup disc?

    MAC Pro, error:You need 4.93 GB of available space to download OS X Mavericks. Remove items from your startup disk to increase available space.
    Where do I locate the startup disc?

    The startup disk is your hard drive, where you store all your programs and data. Probably named Mac HD in Finder. Read this:
    https://discussions.apple.com/message/24370185#24370185

  • My hard drive icon has gone from finder. how do i check available space?

    I normally check my available hard drive space by clicking on the icon hardrive in finder window.  However in Lion its not there. where is it?   How do i check available space?

    Go to Finder Preferences (in the Finder menu) > General tab, make sure the item "Hard Disks" is checkmarked. Once it is, your hard drive's icon should appear on the desktop in the rightmost column.
    You can also maintain a quickly viewable summary. In Finder, go to the View menu and select Show Status Bar. That will add a narrow area at the bottom of each Finder window. In that area will be shown the amount of free space remaining on the drive, as well as the number of items in that folder.

  • The content download cannot be performed because there is not enough available space in cache or the disk is full.

    I deploy all office package via Application deployment. But many system getting failed due to error "The content download
    cannot be performed because there is not enough available space in cache or the disk is full.".
    I delete the cache old file/folder. Now the cache disk space is available. But still this systems showing same error. And it is not retry also. need help for retry application download if failed due to cache disk.

    You should review what your default client cache size is being set to (default 5GB) and then look at the size of the office content you are trying to deliver.
    If the content of the office application exceeds your maximum client cache size setting then the download and subsequent installation will fail.
    Note that normally the download of applications should overwrite old content in the cache unless you have set them to be persistent, the exception to this is the above case.
    To resolve this you will need to increase the client cache size. There are a few ways to achieve this, you can do this either from the Config Manager console via right click tools or via a script that you can run against your clients. Others might like to
    comment on how best to achieve this (if this is indeed your problem).
    Cheers
    Damon

  • Hard drive available space shown incorrectly in finder

    Hi,
    I noticed that my Finder status bar shows incorrect amount of available space. Actually the amount of available space is larger that the actual disk size. The same problem is experienced if I click "Get Info" on my Macintosh HD. It also shows drive capacity as 249.82GB and Available as 252.7GB.
    All the other tools, for example Disk Utility and About this Mac/Storage show the correct information, which is that I have 115.46GB of free space on my Macintosh HD.
    Any idea what could cause this? Or has anyone else experienced similar problems?
    Oh, and I have Filevault 2 turned on.
    //ilari

    Maybe I should be a bit more specific:
    Currently the Get Info for Macintosh HD shows the following:
    Capacity: 249.82 GB
    Available: 282.69 GB
    Used: -- bytes (-- KB on disk)
    While for example df -k shows the following (which is accurate):
    $ df -k
    Filesystem                        1024-blocks      Used Available Capacity  Mounted on
    /dev/disk1                          243966468 152025216  91685252    63%    /
    devfs                                     181       181         0   100%    /dev
    map -hosts                                  0         0         0   100%    /net
    map auto_home                               0         0         0   100%    /home
    localhost:/ezioMnNoyRVU8Vj-YxC4cJ   243966468 243966468         0   100%    /Volumes/MobileBackups
    No matter which way you look at it, the Finder currently calculates the available (free) space incorrectly.
    //ilari

Maybe you are looking for