Professional Documents
Culture Documents
Practice 26
Practice Target
In this practice, you will perform the following:
• Demonstrate the impact of undersized redo log files on database performance
• Use redo log file size advisor to determine the optimal redo log file size
Caution: Do not proceed with performing the practice without taking snapshot first.
Note:
In the following steps, you will create multiple script files. If you want to save your time and create
all those scripts in one command, find attached the file tune_redo_scripts.txt file. Copy/paste
its contents into the Putty window.
The script kicks off a number of SQL*Plus sessions in parallel. The number of SQL*Plus sessions
is to be passed to the script. Each session executes update_orders.sql script.
chmod +x update_orders.sh
The script keeps updating the ORDERS table for N number of seconds. The value of N is to be
passed to the script.
cat > update_orders.sql <<EOL
DECLARE
N NUMBER := &1;
V TIMESTAMP;
X NUMBER ;
SECONDS NUMBER;
BEGIN
DBMS_APPLICATION_INFO.SET_MODULE( MODULE_NAME=> 'CRM', ACTION_NAME=>
'UPDATE_CUST');
V := SYSTIMESTAMP;
SECONDS := 0 ;
WHILE SECONDS < N LOOP
SECONDS := (EXTRACT( MINUTE from SYSTIMESTAMP - V )*60) + EXTRACT( SECOND from
SYSTIMESTAMP - V );
UPDATE ORDERS SET COST_OF_DELIVERY = COST_OF_DELIVERY + 0 WHERE ORDER_ID =
ROUND(DBMS_RANDOM.VALUE(10000,1000000));
COMMIT;
END LOOP;
END;
/
EOL
7. In the Putty window, invoke SQL*Plus and login to ORADB as sysdba. In the rest of this practice,
this session will be referred to as the admin window.
sqlplus / as sysdba
set sqlprompt "ADMIN> "
@ display_log_members.sql
9. Perform the following steps to drop the current redo log files and replace them with 10MB files.
# add three new redo log groups of size 10M each
# Note: the members will automatically be created
ALTER DATABASE ADD LOGFILE GROUP 4 SIZE 10M;
ALTER DATABASE ADD LOGFILE GROUP 5 SIZE 10M;
ALTER DATABASE ADD LOGFILE GROUP 6 SIZE 10M;
# verify that the groups 1,2,and 3 are inactive so that we can drop them
@ display_log_members.sql
# verify that only groups 4,5, and 6 are only available now:
@ display_log_members.sql
10. Start another Putty session and connect to srv1 as oracle. In the rest of this practice, this
session will be referred to as the client window.
11. In the admin window, run the following code to create two AWR snapshots within 2 minutes.
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
JOB_NAME => 'CREATE_2_AWR_SNAPSHOTS',
JOB_TYPE => 'PLSQL_BLOCK',
JOB_ACTION => 'BEGIN DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT(); END;',
START_DATE => SYSDATE,
REPEAT_INTERVAL => 'FREQ=MINUTELY;INTERVAL=2',
END_DATE => SYSDATE + (1/24/60*3),
AUTO_DROP => TRUE,
ENABLED => TRUE);
END;
/
12. In the client window, run the following script. The script kicks off 4 SQL*Plus sessions for 2
minutes. Do not wait for the script to finish its execution. Go to the next step.
./update_orders.sh 4 120
13. In the admin window, run the following script several times to check the redo log switch
frequency:
From the output of the script, we can know that the database is rapidly switching the redo log
files.
As a general rule of thumb, redo log switch should happen once every twenty minutes when the
system is under normal workload.
@ display_log_history.sql
14. Run the following query several times to check on the rate at which the 'redo log space
requests' event is being incremented.
'redo log space requests' event occurs every time the current log group is full and therefore
LGWR is waiting for the log switch to finish to write into the new log group.
SELECT NAME, VALUE FROM V$SYSSTAT WHERE NAME= 'redo log space requests';
17. Generate an AWR report using the last created two snapshots.
Copy the generated report file to the shared folder directory /media/sf_extdisk/
@ ?/rdbms/admin/awrrpt.sql
18. Open the AWR report in your favorite browser. Follow the strategy that you learnt on reading
AWR to troubleshoot the bottleneck.
Note: set this parameter to a high value because we concentrate on the database performance
rather than the instance recovery.
Note: Advisor value is influenced by the current workload. In real life scenario, it should be
consulted when the database is under normal workload.
Note: 'Effective MTTR Target' the MTTR target that the database can achieve.
Clean up
23. Restore srv1 from the snapshot taken in the beginning of the practice
25. (optional) Delete the generated AWR report files from the staging folder
Summary
• Having undersized redo log files could have a serious performance impact on the entire
database performance
• Redo log file size advisor could be used to determine the optimal redo log file size