Practice 24 - Using Smart Flash Cache

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Practice 24 - Using Smart Flash Cache P a g e |1

Practice 24

Using Smart Flash Cache

Practice Target
In this practice, you will perform the following:
• Configure the Smart Flash Cache

• Monitor 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.

Oracle Database Performance Tuning, a course by Ahmed Baraka


Practice 24 - Using Smart Flash Cache P a g e |2

Preparing the Practice Environment


In this section of the practice, you will perform steps to prepare your environment for this practice.

1. In Oracle VirtualBox manager, take a snapshot of srv1.

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.

3. Create the following script SQL*Plus script file, named as display_flashstats.sql

The script displays the basic flash cache statistics.


cat > display_flashstats.sql <<EOL
col "Disk Name" for a15

SELECT NAME "Disk Name", BYTES/1024/1024 "Disk Size (MB)", SINGLEBLKRDS


"Reads#", SINGLEBLKRDTIM_MICRO "Disk Latency (us)"
FROM V\$FLASHFILESTAT;

EOL

4. Create the following script SQL*Plus script file, named as display_flashevents.sql

The script displays instance-level flash cache wait events.


cat > display_flashevents.sql <<EOL
col EVENT for a45

SELECT EVENT, AVERAGE_WAIT, TO_CHAR(TIME_WAITED,'999,999,999') TIME_CS


FROM V\$SYSTEM_EVENT
WHERE EVENT LIKE '%flash cache%';
EOL

5. Create the following script SQL*Plus script file, named as display_flashevents.sql

The script displays instance-level wait events on the flash cache I/O operations.
cat > display_flashevents.sql <<EOL
col EVENT for a45

SELECT EVENT, AVERAGE_WAIT, TO_CHAR(TIME_WAITED,'999,999,999') TIME_CS


FROM V\$SYSTEM_EVENT
WHERE EVENT LIKE '%flash cache%';

EOL

Oracle Database Performance Tuning, a course by Ahmed Baraka


Practice 24 - Using Smart Flash Cache P a g e |3

6. Create the following script SQL*Plus script file, named as display_ordblocks.sql

The script displays the number of blocks saved in the buffer cache grouped by their status.
cat > display_ordblocks.sql <<EOL

SELECT BH.STATUS, COUNT(*) BLOCKS


FROM V\$BH BH, DBA_OBJECTS O
WHERE O.OBJECT_ID=BH.OBJD AND O.OBJECT_NAME='ORDERS' AND O.OWNER='SOE'
GROUP BY BH.STATUS;

EOL

Oracle Database Performance Tuning, a course by Ahmed Baraka


Practice 24 - Using Smart Flash Cache P a g e |4

Configuring the Smart Flash Cache


In this section of the practice, you will configure the Smart Flash Cache in the database.

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.

9. Wait for 2 minutes.

10. Invoke SQL*Plus and login to ORADB as sysdba.

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.

show parameter SGA_TARGET


show parameter MEMORY_TARGET

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';

13. Exit from SQL*Plus

14. To mimic flash memory disks, create three disk files of 1GB each of them. Execute the following
code as root.
su -

dd if=/dev/zero of=/mnt/vdisk1 bs=1024 count=1024000


dd if=/dev/zero of=/mnt/vdisk2 bs=1024 count=1024000
dd if=/dev/zero of=/mnt/vdisk3 bs=1024 count=1024000

chown oracle:oinstall /mnt/vdisk1


chown oracle:oinstall /mnt/vdisk2
chown oracle:oinstall /mnt/vdisk3

Oracle Database Performance Tuning, a course by Ahmed Baraka


Practice 24 - Using Smart Flash Cache P a g e |5

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;

16. Specify the disk sizes to the parameter DB_FLASH_CACHE_SIZE.


Note: Observe there is no single quote for the value assigned to the parameter.
ALTER SYSTEM SET DB_FLASH_CACHE_SIZE=1G, 1G, 1G SCOPE=SPFILE;

17. Stop Swingbench sessions.

18. Restart the database.


SHUTDOWN IMMEDIATE
STARTUP

Oracle Database Performance Tuning, a course by Ahmed Baraka


Practice 24 - Using Smart Flash Cache P a g e |6

Monitoring the Smart Flash Cache


In this section of the practice, you will monitor the Smart Flash Cache in the database.

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;

20. Start Swingbench sessions.

21. Wait for 3 minutes.

22. Run the following script to display the basic statistics on the configured Flash Cache.
@ display_flashstats.sql

23. Display the instance-level flash cache wait events.


@ display_flashevents.sql

24. Retrieve the size of the SOE.ORDERS table.


The table size is nearly 200 MB. This is quite large table that will replace much of the buffer
cache if its blocks are saved in the buffer cache.
SELECT SEGMENT_NAME, BYTES/1024/1024 SIZE_MB
FROM DBA_SEGMENTS
WHERE OWNER='SOE' AND SEGMENT_NAME ='ORDERS' AND SEGMENT_TYPE='TABLE';

25. For the ORDERS table, set the option FLASH_CACHE to the KEEP value.

ALTER TABLE SOE.ORDERS STORAGE (FLASH_CACHE KEEP);

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

Oracle Database Performance Tuning, a course by Ahmed Baraka


Practice 24 - Using Smart Flash Cache P a g e |7

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

34. Stop Swingbench sessions

35. Exit from Putty sessions

36. Shutdown srv1 machine

37. Restore srv1 from the snapshot taken in the beginning of the practice

38. Delete the snapshot

Oracle Database Performance Tuning, a course by Ahmed Baraka


Practice 24 - Using Smart Flash Cache P a g e |8

Summary

• Smart Flash Cache extends the buffer cache into storage.

• We have control on which object blocks could be written to Smart Flash Cache

Oracle Database Performance Tuning, a course by Ahmed Baraka

You might also like