• Data Compression
• Partitioning
. 1
Data Compression
. 2
What is Data Compression?
. 3
• Data Compression occurs when…
. 4
Types Of Data Compression
• Table compression
. 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
. 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
. 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.
. 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
. 13
Partitioning
. 14
What is partitioning?
• In short, it is breaking up of huge data into small,
manageable pieces.
. 15
Why use partitioning?
• Each partition can be managed / operated upon
individually.
Eg: ADD, DROP, SPLIT, ANALYZE etc.
• Better availability
Eg: while one partition is unavailable, others can be
used.
. 16
• Partitions can be scanned in parallel, DML’s in
parallel
. 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
. 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' );
. 25
• The output from SQL Tuning Advisor looks like :
. 26
• SQL Access Advisor :
• Helps to define / drop indexes and mviews with respect to
a workload while tuning a query.
. 27
• The steps to use SQL Advisor are :
– Create a task
– Define a workload
– Generate recommendations
– View recommendations
. 28
Create an advisor task
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
. 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
. 32
• Some practical scenarios of usage
. 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.
. 36
– The GATHER_STATS_JOB job executes procedure
GATHER_DATABASE_STATS_JOB_PROC of
DBMS_STATS package.
. 37
Other Statistics collected
. 38
. 39