Anda di halaman 1dari 39

10g Performance Tuning

• Data Compression

• Resumable Space Allocation

• Partitioning

• SQL Tuning Advisors

• Optimizer and 10g

. 1
Data Compression

. 2
What is Data Compression?

• It is mechanism to eliminates duplicate values in a


block.
• Duplicate values in rows and columns are stored at
the beginning of the block which is called as symbol
table.
• Occurrences of duplicate values are replaced with a
short reference to a symbol table.

. 3
• Data Compression occurs when…

… data is being bulk inserted or bulk loaded or


specifically as in following ways:
– Direct Path SQL*Loader
– Create Table ... As Select statement
– Parallel INSERT (or serial INSERT with an APPEND
hint) statement
– Moving data into compressed form through “Alter
Table table_name Move compress” statement

. 4
Types Of Data Compression
• Table compression

CREATE TABLE t1 COMPRESS;


Index key compression

CREATE INDEX emp_unq ON


emp_comp(emp_no) COMPRESS;

. 5
Usage
• Space savings of about 50%
• Query speed up
• Can be used for older partitions of DWH / Orders
• Can be used for repository tables of Focass
• Can be used for History tables in Prism

. 6
Resumable
Space Allocation

. 7
Introduction
• Means of
– Suspending an operation in case of space related
error
– Automatically resuming it when the error is handled

• Enables to take a corrective action, instead of receiving


an error.

• A resumable statement can be suspended and


resumed multiple times during execution.

. 8
Cycle
– Resumable Space allocation is enabled.
– Operation begins.
– The resumable operation is suspended due to
some space allocation failure.
– Error is written to alert-log file.
– Error is detected and fixed.
– for e.g. space is added to the tablespace.
– The Suspended operation resumes automatically.
– Operation ends successfully.

. 9
• What errors are correctable?
– Out of space condition
– Space Quota exceeded condition
– Maximum extents reached condition

• What operations are resumable?


– Queries
– Import / Export / SQL*Loader
– DML
– DDL
Remote operations are not supported

. 10
• Detecting Suspended Statements
– From Alert log file
– Querying dictionary views - DBA_RESUMABLE /
USER_RESUMABLE
– AFTER SUSPEND system event trigger

• DBMS_RESUMABLE package
– ABORT(sessionId)
– GET_TIMEOUT( )
– SET_TIMEOUT(timeout)

. 11
• Resumable Operations Naming and Timeout:
– For easy identification of statements when
querying dictionary views resumable sessions can
be named.
– When you enable resumable mode for a session,
you can also specify a timeout interval.
– If no intervention has taken place till timeout, then
suspended statement will fail with error.

• ALTER SESSION ENABLE RESUMABLE TIMEOUT


3600 NAME ‘TRANS1’;

. 12
• Benefits with Resumable Space Allocation :
– No Failure
– Process is suspended in case of space issues
– Generates alerts and maintains the data dictionary
– Resumes automatically as soon as space is added.
– Time saved

• Can be widely used for:


– DWH Loading process
– Day end processes in clearing applications
– Long Running standard or adhoc queries

. 13
Partitioning

. 14
What is partitioning?
• In short, it is breaking up of huge data into small,
manageable pieces.

• Each piece is called as partition or sub-partition


depending on how partitioning was implemented.

• Both Tables and Indexes can be partitioned.

. 15
Why use partitioning?
• Each partition can be managed / operated upon
individually.
Eg: ADD, DROP, SPLIT, ANALYZE etc.

• Reduced downtime for maintenance operations.


Eg: Table reorganization, Index rebuilds etc.

• Better availability
Eg: while one partition is unavailable, others can be
used.

. 16
• Partitions can be scanned in parallel, DML’s in
parallel

• Partitioning is transparent to applications though


partition extended table names can be used to work
with individual partitions.

• PARTITION PRUNING : Optimizer eliminates


partitions that do not need to be scanned.

. 17
Types Of Partition
• RANGE Partitioning
• HASH Partitioning
• LIST Partitioning
• Composite Range-Hash partitioning
• Composite Range-List partitioning

. 18
Types of Indexes
Local Index
– Equi-partitioned with base table.
– Entries in an Index partition point to single table
partition.
– Easy to manage + more availability.
Global Index
– Entries in an index partition may point to more than
one table partition.
– Now we can specify UPDATE GLOBAL INDEXES
option of ALTER TABLE command.

. 19
Common operations involved
• Adding partitions ADD PARTITION
• Removing partitions DROP PARTITION
• Exchanging partitions EXCHANGE PARTITION
• Splitting a partition SPLIT PARTITION
• Modifying attributes MODIFY PARTITION
• Rebuilding index partitions REBUILD PARTITION

. 20
SQL Tuning
Advisors

. 21
SQL Tuning Advisor
• This advisor analyzes SQL statements and makes
recommendations for improving performance.
• SQL Tuning Advisor takes one or more SQL statements
as input and gives it to the Automatic Tuning Optimizer.
• Input sources :
– ADDM High Load SQL
– AWR
– Cursor Cache
– SQL Tuning Set

. 22
• The SQL Tuning Advisor can be used for the following
types of tuning :
– Reactive Tuning :Input from ADDM
– Proactive Tuning :Input from cursor cache
– Development Tuning : Input from SQL Tuning Set

• The SQL Tuning Advisor can be run from OEM or using


the package DBMS_SQLTUNE.

. 23
• Using DBMS_SQLTUNE
– Create a Tuning task as follows :
– begin
– my_sqltext:='select cnt from small_val where cnt = 999';
– my_task_name:=
DBMS_SQLTUNE.CREATE_TUNING_TASK (
– sql_text => my_sqltext,
– user_name => ‘IDXDBA',
– scope => 'LIMITED',
– time_limit => 60,
– task_name => 'my_sql_tuning_task',
– description => 'Task to tune a query on a specified
employee');
– End;

. 24
• Execute the task as follows :
exec DBMS_SQLTUNE.EXECUTE_TUNING_TASK
(task_name => 'my_sql_tuning_task' );

• The various dictionary views related to SQL Tuning


Advisor are :
– DBA_ADVISOR_TASKS
– DBA_ADVISOR_FINDINGS
– DBA_ADVISOR_RATIONALE

• View the recommendations as follows :


SELECT DBMS_SQLTUNE.REPORT_TUNING_TASK
('my_sql_tuning_task') from dual;

. 25
• The output from SQL Tuning Advisor looks like :

• GENERAL INFORMATION SECTION


• Tuning Task Name : my_sql_tuning_task
• Scope : LIMITED
• Time Limit(seconds): 60
• Completion Status : COMPLETED
• Started at : 04/07/2005 16:06:37
• Completed at : 04/07/2005 16:06:38
• -------------------------------------------------------------------
• SQL ID : c839zuqzt5u5m
• SQL Text: select cnt from small_val where cnt = 999

. 26
• SQL Access Advisor :
• Helps to define / drop indexes and mviews with respect to
a workload while tuning a query.

• The workload can be input from :


– Current SQL activity
– SQL Repository
– User Defined workload

• The output is a set of recommendations.

. 27
• The steps to use SQL Advisor are :
– Create a task
– Define a workload
– Generate recommendations
– View recommendations

• These can be done from OEM or thorough backend using


DBMS_ADVISOR package.

. 28
Create an advisor task

Adjust task parameters

Perform analysis

No
No Accept Yes
Yes
results?

Implement
recommendations

. 29
• The recommendations of SQL Access Advisor can be
viewed as follows :
• SQL> SELECT sql_id, rec_id, precost, postcost,
• 2 (precost-postcost)*100/precost AS
percent_benefit
• 3 FROM USER_ADVISOR_SQLA_WK_STMTS
• 4 WHERE TASK_NAME = :task_name
• 5 /
• SQL_ID REC_ID PRE POST PERCENT_ BENEFIT
• COST COST
• ---------- ---------- ---------- ---------- ---------------
• 1 1 42 3 92.8571429

• We can judge which recommendation is giving most


benefit.

. 30
• Viewing the recommendations in detail :
• SQL> SELECT rec_id, action_id,
SUBSTR(command,1,30) AS command
• 2 FROM user_advisor_actions WHERE task_name =
:task_name
• 3 ORDER BY rec_id, action_id;
• REC_ID ACTION_ID COMMAND
• ---------- ---------- ---------------------------------------------
• 1 1 CREATE MATERIALIZED VIEW LOG
• 1 3 CREATE MATERIALIZED VIEW
• 1 4 GATHER TABLE STATISTICS

. 31
• Benefits of SQL Tuning Advisors:
– Automated generation of recommended solutions
for an input query considering entire workload
– Based on decades of Oracle performance tuning
– Benefits of recommendations quantified

• 10g also supports tuning of packaged applications,


without code change.

• Query Tuning improved potentially from hours to


minutes!!!

. 32
• Some practical scenarios of usage

– Website performance issue: Query tuning could


have been faster with the 10g advisors

– Tuning of queries generated by packaged


applications like Business Objects or Reveleus

– Wide usage across development teams

. 33
Optimizer and 10g

. 34
Optimizer Modes
• ALL_ROWS
• FIRST_ROWS_n
• FIRST_ROWS_1
• FIRST_ROWS_10
• FIRST_ROWS_100
• FIRST_ROWS_1000

• RULE AND CHOOSE are de-supported in 10g

. 35
Optimizer Statistics
• What are statistics?
– Optimizer statistics are a collection of data that
describe more details about the database objects
and the database in general.
– Used by optimizer to choose best execution plan.

• The type of statistics are :


– Table Statistics ( rows , blocks ,avg row length )
– Column Statistics ( NDV , NULLS , Histogram )
– Index Statistics
– System statistics ( I/O , CPU )

. 36
– The GATHER_STATS_JOB job executes procedure
GATHER_DATABASE_STATS_JOB_PROC of
DBMS_STATS package.

– It collects statistics for :


• Objects with no statistics
• Objects with stale statistics ( modified > 10% )
• And gives priority to objects that need updated
statistics
• No system statistics gathered.

– STATISTICS_LEVEL parameter must be set to ALL or


TYPICAL .

. 37
Other Statistics collected

• Object statistics every hour


• System and Session statistics every minute
• ASH (Active Session History ) statistics every second
• AWR Snapshots every hour
• ADDM Reports every hour
• The above statistics / reports will not be collected if
STATISTICS_LEVEL = BASIC

. 38
. 39

Anda mungkin juga menyukai