• Automatic Memory Management can be enabled with the parameter MEMORY_TARGET... Use the SQL Tuning Advisor • The SQL Tuning Advisor performs statistics analysis, SQL Profile analysis, a
Trang 14 Connect as SYSTEM Terminate the capture, and process it:
execute dbms_workload_capture.finish_capture;
execute dbms_workload_replay.process_capture('PLAY_D');
5 Replay the workload Note that when launching the replay client, you must specify the physical path, not the Oracle directory:
exec dbms_workload_replay.initialize_replay('play capture','PLAY_D'); exec dbms_workload_replay.prepare_replay;
In a separate window, launch the client from an operating system prompt:
wrc player/player replaydir=/home/oracle/play_d
In the SQL*Plus session, start the replay:
exec dbms_workload_replay.start_replay;
The illustrations show this step.
Trang 26 To retrieve the replay report, you must first obtain its ID number:
select id,capture_id,directory,start_time,end_time
from dba_workload_replays;
Set the SQL*Plus buffer size, and retrieve the report:
set long 100000
select dbms_workload_replay.report(<id>,'TEXT') from dual;
Study the report, and note the values of the DB Time for the Replay and the
Capture: they will be similar
7 Connected as PLAYER, add a primary key constraint to the table:
alter table t1 add constraint t1_pk primary key (object_id);
8 Repeat Steps 5 and 6 You will observe a significant drop in the DB Time
value, demonstrating the improvement in performance that follows from
defining the constraint
9 Tidy up:
drop user player cascade;
Two-Minute Drill
Use Automatic Memory Management
• Automatic Shared Memory Management can be enabled with the parameter
SGA_TARGET
• Automatic PGA Management can be enabled with the parameter PGA_
AGGREGATE_TARGET
• Automatic Memory Management can be enabled with the parameter
MEMORY_TARGET
Trang 3• Oracle will attempt to recompile invalid procedural object automatically.
• Unusable indexes must be rebuilt manually
• Oracle will not attempt to use an unusable index, by default, so there will be
no errors
Implement Automatic Memory Management
• You configure AMM by setting the parameter MEMORY_TARGET
• MEMORY_MAX_TARGET is an upper bound for MEMORY_TARGET The former is not a dynamic parameter
• When MEMORY_TARGET is set and both SGA_TARGET and PGA_
AGGREGATE_TARGET are set, then SGA_TARGET and PGA_AGGREGATE_ TARGET are used as minimum values
Manually Configure SGA Parameters
• You can set MEMORY_TARGET to zero and SGA_TARGET to a nonzero value
to exercise more control over SGA memory
• Adjustments to automatically tuned SGA parameters are saved across instance restarts
• ASMM uses the MMAN background process to coordinate changes in
memory size
• The five auto-tuned ASMM initialization parameters are SHARED_POOL_SIZE, LARGE_POOL_SIZE, JAVA_POOL_SIZE, DB_CACHE_SIZE, and STREAMS_ POOL_SIZE
• The manually tuned ASMM initialization parameters are DB_KEEP_CACHE_
SIZE, DB_RECYCLE_CACHE_SIZE, DB_nK_CACHE_SIZE, and LOG_BUFFER.
• You can easily disable ASMM by setting SGA_TARGET to zero, but then the current auto-tuned ASMM initialization parameters are set to their current values
• The static parameter SGA_MAX_SIZE is the upper limit for the value of SGA_ TARGET
Trang 4Configure Automatic PGA Memory Management
• The parameter PGA_AGGREGATE_TARGET sets an upper limit for memory
used by all server and background processes and enables auto-tuning of PGA
memory
• PGA memory areas include private SQL areas, named cursors, work areas for
sorting operations, and session-specific memory variables
Use the SQL Tuning Advisor
• The SQL Tuning Advisor performs statistics analysis, SQL Profile analysis,
access path analysis, and structure analysis
• The SQL Tuning Advisor can automatically implement SQL Profiles
• The SQL Tuning Advisor tunes each SQL statement individually
• You can specify a SQL Tuning Set, a workload, recent SQL activity, or a single
SQL statement as input to the SQL Tuning Advisor
Use the SQL Access Advisor to Tune a Workload
• A SQL Access Advisor workload can consist of a single SQL statement, a SQL
Tuning Set, the current SQL cache contents, existing statistics, or a schema
name
• Recommendations from the SQL Access Advisor include new indexes,
materialized views, and partitioning
• The four steps composing a SQL Access Advisor session are: (1) creating the
task, (2) defining the workload, (3) generating the recommendations, and
(4) reviewing and implementing the recommendations
• You can either review usage of existing structures or recommend new
structures in a SQL Access Advisor session
Understand Database Replay
• Database Replay consists of four steps: (1) workload capture, (2) workload
preprocessing, (3) workload replay, and (4) analysis and reporting
• Each recorded client request contains the SQL text, bind values, and
transaction information—including a timestamp
• Client requests such as SQL*Loader operations, Oracle Streams, flashback
queries, distributed transactions, and remote DESCRIBE or COMMIT commands
are not included in the capture operation
• Captured replay information needs to be processed only once for any
number of target environments, and for any number of replays on the
target system
Trang 5A The shared pool
B The large pool
C The Java pool
D The log buffer
E None are fixed, if Automatic Memory Management has been enabled
3 When Automatic Memory Management is enabled, what is not possible? (Choose the best answer.)
A Transfer of memory between sessions’ PGAs
B Transfer of memory between structures within the SGA
C Transfer of memory from SGA to PGA, and vice versa
D Increasing the total memory usage after instance startup
E All of the above are possible
4 Storage of what structures can exist in the PGA? (Choose all correct answers.)
A Shared SQL areas
B Private SQL areas
C Global temporary tables
D Sort areas
E Bitmap merge areas
F Cached object definitions
5 Which instance parameter can disable the memory advisors? (Choose the best answer.)
A DB_CACHE_ADVICE
B MEMORY_TARGET
C STATISTICS_LEVEL
D TIMED_STATISTICS
Trang 66 Which of these parameters cannot be changed without an instance restart?
(Choose all correct answers.)
A MEMORY_MAX_TARGET
B MEMORY_TARGET
C PGA_AGGREGATE_TARGET
D SGA_TARGET
7 If you create a table and a procedure that refers to it, and then change the
definition of the table, what will happen when you try to run the procedure?
(Choose the best answer.)
A The procedure will recompile automatically and run successfully
B The procedure will fail until you recompile it
C The procedure will run with reduced performance until you analyze
the table
D The procedure may or may not compile, depending on the nature
of the change
8 If a SELECT statement attempts to use an UNUSABLE index, what will
happen? (Choose the best answer.)
A The statement will fail
B The statement will succeed, but at reduced performance
C The index will be rebuilt automatically if possible
D It depends on the SKIP_UNUSABLE_INDEXES parameter
9 You determine that an index is unusable, and decide to rebuild it Which of
the following statements, if any, are correct? (Choose all correct answers.)
A The NOLOGGING and ONLINE keywords cannot be used together when
rebuilding the index
B A rebuild may require double the disk space while it is in progress
C If you do not use the ONLINE keyword during a rebuild, the table will be
unavailable for SELECT and DML statements
D The NOLOGGING keyword applied to a rebuild means that DML against
the index will not generate redo
10 If a primary key index becomes unusable, what will be the effect upon an
application that uses it? (Choose the best answer.)
A SELECT will succeed, but perhaps at reduced performance
B DML commands will succeed, but perhaps at reduced performance
C The primary key constraint can no longer be enforced
D The table may be locked for DML
Trang 7A Structure analysis
B SQL Profile analysis
C Access paths
D Changes to materialized views
E Statistics analysis
13 Which of the following can you use as input for the SQL Tuning Advisor?
(Choose all that apply.)
A A single SQL statement provided by a user
B An existing SQL Tuning Set (STS)
C A preprocessed Database Replay workload
D A schema name
E A SQL statement identified in EM as using excessive resources
14 Which of the following procedures will run a SQL Tuning Advisor job against
a SQL Tuning Set? (Choose the best answer.)
A DBMS_QUICKTUNE.EXECUTE_TUNING_TASK
B DBMS_SQLTUNE.EXECUTE_TUNING_TASK
C DBMS_SQLTUNE.RUN_TUNING_TASK
D DBMS_ADVISOR.EXECUTE_TUNING_TASK
15 Which of the following can you use as input for the SQL Access Advisor?
(Choose all that apply.)
A A single SQL statement provided by a user
B An existing SQL Tuning Set (STS)
C A preprocessed Database Replay workload
D A schema name
E Current SQL cache contents
16 Which of the following changes can the SQL Access Advisor recommend?
(Choose two answers.)
A Restructuring one or more SQL statements
Trang 8B Gathering statistics for selected SQL statements
C Adding a materialized view log
D Enabling query rewrite
17 Which of the following procedures will run a SQL Access Advisor job against
a single SQL statement? (Choose the best answer.)
A DBMS_QUICKTUNE.EXECUTE_TUNING_TASK
B DBMS_ADVISOR.EXECUTE_TUNING_TASK
C DBMS_SQLTUNE.RUN_TUNING_TASK
D DBMS_ADVISOR.QUICK_TUNE
E The SQL Access Advisor requires a workload, AWR snapshot, or STS and
cannot analyze a single SQL statement
18 You want to remap your database links so that they do not reference
production database objects Within which Database Replay step do
you perform the remapping? (Choose the best answer.)
A During the workload replay step
B During the workload preprocessing step
C During the workload capture step
D Before the workload capture starts
E You do not need to remap, since it happens automatically
19 Which of the following database client operations are captured during
Database Replay? (Choose all that apply.)
A A flashback query
B Distributed transactions
C Oracle Streams operations
D A CREATE TABLE statement
E A transaction started before capturing begins
Self Test Answers
1 þ A Private SQL areas are private to each session, in the session’s PGA.
ý B, C, and D B is wrong because automatic PGA management is not
relevant to where the private SQL area is stored, only to how it is managed
C and D are wrong because private SQL areas are always in the PGA.
2 þ D The log buffer cannot be changed after startup.
ý A, B, C, and E A, B, and C are wrong because all these structures can be
resized E is wrong because not even Automatic Memory Management makes
the log buffer resizable
Trang 9not run.
ý A, D, and B A and D are wrong, because these parameters (which still
exist only for backward compatibility) are controlled by STATISTICS_LEVEL
B is wrong because MEMORY_TARGET determines whether implementing the
advice is automatic or manual
6 þ A MEMORY_MAX_TARGET is a static parameter: it cannot be changed
without restarting the instance
ý B, C, and D All these parameters are dynamic, meaning that they can be
changed without restarting the instance
7 þ D Oracle will attempt recompilation, but this may not succeed.
ý A, B, and C A is wrong because this will not necessarily succeed if the nature of the change is such that the procedure needs to be rewritten B is
wrong because manual recompilation is not necessary (though it may be
a good idea) C is wrong because it refers to object statistics, which are not
relevant to a problem of this kind
8 þ D The SKIP_UNUSABLE_INDEXES parameter will control whether the
statement produces an error or reverts to an alternative plan
ý A, B, and C A and B are both wrong because they make an assumption about the SKIP_UNUSABLE_INDEXES parameter: A assumes it is false; B assumes it is true C is wrong because indexes are never rebuilt automatically.
9 þ B A rebuild requires additional space, as the new index is built before the
original index is dropped
ý A, C, and D A is wrong because NOLOGGING and ONLINE can be used together C is wrong because without ONLINE the index is locked for DML, but not for SELECT D is wrong because DML always generates redo—it is
only the DDL that will not generate redo
10 þ D Loss of a primary key index means that DML against the constrained
column(s) will be impossible
Trang 10ý A, B, and C A is wrong because this is not certain—it is dependent on the
SKIP_UNUSABLE_INDEXES setting B is wrong because DML commands will
fail if they affect the constrained column(s) C is wrong because the constraint
will be enforced—by locking the table
11 þ D MEMORY_TARGET enables AMM; it is a dynamic parameter and
cannot be more than MEMORY_MAX_TARGET
ý A, B, and C A is wrong because the MEMORY_MAX_TARGET can be left on
default B is wrong because MEMORY_TARGET is dynamic C is wrong because
while MEMORY_MAX_TARGET provides a limit for AMM, it does not enable it
12 þ D Only the SQL Access Advisor recommends changes to materialized
views, including creating materialized view logs
ý A, B, C, and E The SQL Tuning Advisor performs statistics analysis, SQL
Profiling, access paths, and structure analysis
13 þ A, B, and E The SQL Tuning Advisor can use currently running SQL
statements, a single statement provided by any user, an existing SQL Tuning
Set, or historical SQL statements from AWR snapshots
ý C and D C is wrong because you cannot use Database Replay workloads
to specify SQL for the SQL Tuning Advisor D is wrong because you cannot
specify a schema or table names; you can only specify SQL statements
14 þ B DBMS_SQLTUNE.EXECUTE_TUNING_TASK runs a SQL Tuning
Advisor task created with DBMS_SQLTUNE.CREATE_TUNING_TASK
ý A, C, and D These are not valid packages or procedures.
15 þ A, B, D, and E In addition to a single SQL statement (using QUICK_
TUNE), an existing STS, a schema name, and current SQL cache contents, the
SQL Access Advisor also uses statistics to analyze overall SQL performance
ý C C is wrong because you cannot use the captured Database Replay
information as a source for the SQL Access Advisor
16 þ C and D The SQL Access Advisor recommends materialized views,
materialized view logs, and enabling query rewrite In addition, the SQL
Access Advisor will also recommend new indexes or partitions
ý A and B The SQL Tuning Advisor recommends SQL statement
restructuring and statistics gathering, not the SQL Access Advisor
17 þ D DBMS_ADVISOR.QUICK_TUNE runs an analysis on a single SQL
statement You provide the name of the tuning task, which the procedure
automatically creates, along with the SQL to be tuned
ý A, B, C, and E A, B, and C are wrong because these procedures do not
exist E is wrong because the SQL Access Advisor can run an analysis on a
single SQL statement, just as the SQL Tuning Advisor can