8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | 21c | 23c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux

Home » Articles » 12c » Here

Database Smart Flash Cache in Oracle Database 12c Release 1

The Database Smart Flash Cache functionality was originally released in 11.2.0.2. In Oracle Database 12c the Smart Flash Cache can now use multiple flash disks without needing a volume manager. I'm not sure why this makes it worthy of inclusion in the 12c OCP DBA exam, since it seems like a very minor change.

The feature works as expected in Oracle 12.2 on OL6 and OL7. It feature works in Oracle 12.1 on OL5 and OL6, but you must apply Patch 19504946 for it to work on OL7 (see MOS Doc ID 2123908.1.

Introduction

The Smart Flash Cache feature is available on Solaris and Oracle Linux platforms. It allows you to define a second tier of buffer cache on flash disks to improve performance. Normally, when items are aged out of the buffer cache they must be reloaded from disk the next time they are required. With Smart Flash Cache, the aged out items are placed in the Smart Flash Cache, so if they are needed again they are reloaded more quickly into the buffer cache, rather than having to come from slow disks.

The documentation suggest that optimum performance is seen when the Smart Flash Cache is 2-10 times the size of the buffer cache. In this example I have a buffer cache of approximately 1G, so I need a Smart Flash Cache of 2G or more.

I don't have any flash storage to play with on this machine, so I'm going to fake two disks to allow me to use the feature. Doing this is a really stupid idea on a real system!

# dd if=/dev/zero of=/mnt/vdisk1 bs=1024 count=1024000
# dd if=/dev/zero of=/mnt/vdisk2 bs=1024 count=1024000
# chown oracle:oinstall /mnt/vdisk1 /mnt/vdisk2

So, let's assume I had real flash disks, or partitions on real flash disks. In this case my fake disks are named "/mnt/vdisk1" and "/mnt/vdisk1".

Metadata about the contents of the Smart Flash Cache is maintained in the buffer cache, so if you don't take this into account, your actual buffer cache size is effectively reduced by using the Smart Flash Cache. To counter this, increase the buffer cache by approximately 100 bytes multiplied by the number of blocks you expect to cache in the Smart Flash Cache. In RAC installations you also need to consider the size of the shared pool. Approximately 208 bytes should be allocated for each GCS resource.

Enable Smart Flash Cache

The DB_FLASH_CACHE_FILE parameter is used to identify the flash disks to be used by the Smart Flash Cache.

ALTER SYSTEM SET DB_FLASH_CACHE_FILE = '/mnt/vdisk1', '/mnt/vdisk2' SCOPE=SPFILE;

The size of the individual disks is specified by the DB_FLASH_CACHE_SIZE parameter.

ALTER SYSTEM SET DB_FLASH_CACHE_SIZE = 1G, 1G SCOPE=SPFILE;

Restart the database.

SHUTDOWN IMMEDIATE;
STARTUP;

Once started, you can see the parameters are set correctly.

SQL> SHOW PARAMETER db_flash_cache

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_flash_cache_file                  string      /mnt/vdisk1, /mnt/vdisk2
db_flash_cache_size                  big integer 1G, 1G
SQL>

Information about Smart Flash Cache usage is displayed using the V$FLASHFILESTAT view.

SET LINESIZE 100
COLUMN name FORMAT A20

SELECT * FROM v$flashfilestat;

FLASHFILE# NAME                      BYTES    ENABLED SINGLEBLKRDS SINGLEBLKRDTIM_MICRO     CON_ID
---------- -------------------- ---------- ---------- ------------ -------------------- ----------
         1 /mnt/vdisk1          1073741824          1            0                    0          0
         2 /mnt/vdisk2          1073741824          1            0                    0          0

SQL>

Disable Smart Flash Cache

Resetting the initialization parameters disables the Smart Flash Cache.

ALTER SYSTEM RESET DB_FLASH_CACHE_FILE SCOPE=SPFILE;
ALTER SYSTEM RESET DB_FLASH_CACHE_SIZE SCOPE=SPFILE;
SHUTDOWN IMMEDIATE;
STARTUP;

SELECT * FROM v$flashfilestat;

no rows selected

SQL>

Modifying Table Usage

The default action is for blocks to be aged out of the buffer cache and into the Smart Flash Cache. The FLASH_CACHE clause of the ALTER TABLE command allows additional control.

-- Prevent EMP from using the Smart Flash Cache.
ALTER TABLE scott.emp STORAGE (FLASH_CACHE NONE);

-- Force EMP to remain in the Smart Flash Cache, space provided.
ALTER TABLE scott.emp STORAGE (FLASH_CACHE KEEP);

-- Reset EMP to default use of Smart Flash Cache.
ALTER TABLE scott.emp STORAGE (FLASH_CACHE);
ALTER TABLE scott.emp STORAGE (FLASH_CACHE DEFAULT);

Performance

As always, you need to be careful about testing the performance impact of using the Smart Flash Cache. Several people have reported better performance when using flash disks for actual data files, rather than using them for the Smart Flash Cache. Your results may vary depending on the hardware you are using and the type of processing done by your database.

For more information see:

Hope this helps. Regards Tim...

Back to the Top.