Practice 24 - Using Smart Flash Cache
Practice 24 - Using Smart Flash Cache
Practice 24
Practice Target
In this practice, you will perform the following:
• Configure the Smart Flash Cache
Note
Because our environment is based on a VirtualBox appliance and because we do not have SSD
attached to it, we cannot test the Smart Flash Cache for performance. This practice is to
demonstrate its functionality.
Caution: Do not proceed with performing the practice without taking snapshot first.
2. Start Putty and connect to srv1 as oracle. In the rest of this practice, this session will be
referred to as admin window.
Note: Unless stated otherwise, all the steps in this practice should be run in the admin window.
EOL
The script displays instance-level wait events on the flash cache I/O operations.
cat > display_flashevents.sql <<EOL
col EVENT for a45
EOL
The script displays the number of blocks saved in the buffer cache grouped by their status.
cat > display_ordblocks.sql <<EOL
EOL
7. In the hosting PC, open a command prompt window and start Swingbench.
D:
cd D:\swingbench\winbin
set PATH=D:\oracle\product\12.1.0\client_1\jdk\jre\bin;%PATH%
swingbench.bat
8. In Swingbench, open the oltp.xml configuration file then click on the Start Benchmark button.
sqlplus / as sysdba
set sqlprompt "ADMIN> "
11. Check which memory management configuration is being used in the database.
The parameter SGA_TARGET is set, which means the AMM is being configured in the database.
12. Display the current buffer cache set by the automatic memory management (AMM) configuration.
In my environment, the buffer cache was about 1.2 GB. Therefore, creating a flash cache of 3 GB
is fair enough.
SELECT CURRENT_SIZE/1024/1024 MB FROM V$MEMORY_DYNAMIC_COMPONENTS WHERE
COMPONENT='DEFAULT buffer cache';
14. To mimic flash memory disks, create three disk files of 1GB each of them. Execute the following
code as root.
su -
15. Invoke SQL*Plus, login to ORADB as sysdba then use the created disks to configure the Smart
Flash Cache in the database.
In a real life scenario, the space taken by the metadata in the buffer cache should be taken into
the consideration.
su - oracle
sqlplus / as sysdba
ALTER SYSTEM SET DB_FLASH_CACHE_FILE = '/mnt/vdisk1', '/mnt/vdisk2',
'/mnt/vdisk3' SCOPE=SPFILE;
19. Set the CACHE option on the ORDERS table to force the database to cache the table blocks in the
buffer cache when the table is accessed by FTS operations.
ALTER TABLE SOE.ORDERS CACHE;
22. Run the following script to display the basic statistics on the configured Flash Cache.
@ display_flashstats.sql
25. For the ORDERS table, set the option FLASH_CACHE to the KEEP value.
26. Start another Putty session and connect to srv1 as oracle. Invoke SQL*Plus and login to ORADB
as soe. In the rest of this practice, this session will be referred to as the client window.
sqlplus soe/soe
set sqlprompt "CLIENT> "
27. In the client window, run the following query. Do not wait for the query to finish. Go to the next
step.
SELECT ORDER_ID, ORDER_TOTAL FROM ORDERS;
28. In the admin window, display the Flash Cache statistics and wait events.
@ display_flashstats.sql
@ display_flashevents.sql
29. Display the number of ORDERS blocks written into the buffer cache.
Some blocks are in the buffer cache and some of them are written in the flash cache.
@ display_ordblocks.sql
30. In the client window, cancel the running query by pressing on [Ctl]+[c], if it is not already
finished.
31. For the ORDERS table, set the option FLASH_CACHE to the NONE value.
With this option, the table blocks will not be written into the flash cache.
ALTER TABLE SOE.ORDERS STORAGE (FLASH_CACHE NONE);
32. In the client window, run the query in the client session again.
/
33. Display the number of ORDERS blocks written into the buffer cache.
No block is written into the flash cache.
@ display_ordblocks.sql
Clean up
37. Restore srv1 from the snapshot taken in the beginning of the practice
Summary
• We have control on which object blocks could be written to Smart Flash Cache