DBA Hub

📋Steps in this guide1/5

Database Smart Flash Cache in Oracle Database 12c Release 1

Learn how to configure and use the Database Smart Flash Cache in Oracle Database 12c Release 1.

oracle 12cconfigurationintermediate
by OracleDba
14 views
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! 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.

Code/Command (click line numbers to comment):

1
2
3
# 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
2

Enable Smart Flash Cache

The parameter is used to identify the flash disks to be used by the Smart Flash Cache. The size of the individual disks is specified by the parameter. Restart the database. Once started, you can see the parameters are set correctly. Information about Smart Flash Cache usage is displayed using the view.

Code/Command (click line numbers to comment):

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
ALTER SYSTEM SET DB_FLASH_CACHE_FILE = '/mnt/vdisk1', '/mnt/vdisk2' SCOPE=SPFILE;

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

SHUTDOWN IMMEDIATE;
STARTUP;

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>

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>
3

Disable Smart Flash Cache

Resetting the initialization parameters disables the Smart Flash Cache.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
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>
4

Modifying Table Usage

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

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
-- 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);
5

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: - Configuring Database Smart Flash Cache - DB_FLASH_CACHE_FILE - DB_FLASH_CACHE_SIZE - storage_clause : FLASH_CACHE Hope this helps. Regards Tim...

Comments (0)

Please to add comments

No comments yet. Be the first to comment!