Sunday, February 28, 2010

How To Clear DB Blocks In Flash Cache

For each database block moved from the buffer cache to the flash cache. We check...
SELECT
SUM (CASE WHEN b.status LIKE 'flash%' THEN 1 else 0 END) flash_blocks, SUM
(CASE WHEN b.status LIKE 'flash%' THEN 0 else 1 END) cache_blocks,
count(*) total_blocks
FROM v$bh b
/
We'll see number of database blocks in flash cache.
FLASH_BLOCKS CACHE_BLOCKS TOTAL_BLOCKS
------------ ------------ ------------
3132 3427 6559
We see 3132 blocks in flash cache.
How to clear database blocks in flash cache?

- Disable Flash Cache
SQL> show parameter db_flash_cache_size

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_flash_cache_size big integer 20G

SQL> alter system set db_flash_cache_size=0;

System altered.

SQL> show parameter db_flash_cache_size

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_flash_cache_size big integer 0
Check
FLASH_BLOCKS CACHE_BLOCKS TOTAL_BLOCKS
------------ ------------ ------------
0 3427 3427
- Flush Buffer Cache
The FLUSH BUFFER_CACHE clause lets you clear all data from the buffer cache in the system global area (SGA), including the KEEP, RECYCLE, and DEFAULT buffer pools.
I'm curious with it, so test & check.
FLASH_BLOCKS CACHE_BLOCKS TOTAL_BLOCKS
------------ ------------ ------------
2404 3382 5786
Alter system...
SQL> alter system flush buffer_cache;

System altered.
Check
FLASH_BLOCKS CACHE_BLOCKS TOTAL_BLOCKS
------------ ------------ ------------
0 3382 3382
After, I flushed buffer_cache, I don't see database block in flash cache. However I think we should use Disable Flash Cache.
This is just fun for test system, don't flush buffer cache on production system.

No comments: