Beruflich Dokumente
Kultur Dokumente
3 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Agenda
Understand the challenges with Retail Application performance<Insert
Picture
Find the key factors affecting Retail Application performance Here>
4 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
<Insert
Picture
Here>
SECTION 1
5 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Why Retail Application Performance is a
Challenge
Logic complexity
Many analytical functions and cross-row computations
Many UNION and OR statements to cover all the scenarios
SQL length often measured by pages
Data volume
One of the industries with the largest data volume
Data processed can be at Item/Loc/Date level
Often 10s million line/item transactions per day
The largest tables are the frequently accessed tables
6 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Why Retail Application Performance is a
Challenge
Data Model complexity
Data model designed for RMS, and shared with many other
Oracle Retail applications
Flexibility of application
Many Oracle Retail Applications are very flexible, and can be
setup and used in different ways
Different business practices
Each customer has its unique business process and data profile
7 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Why Retail Application Performance is a
Challenge
Rapidly growing tables and difficult to purge
Hard to set up data to test every block of application
code
Different data will hit different code block
Different data generates different SQL Execution Plan
Different server objects
PL/SQL object table no statistics available
Staging/working tables No data when the gather Statistics job is
running, but with data there when the application is running
8 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Key Factors for Performance
9 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Key Factors for Performance
10 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Where to Tune?
11 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Performance Testing Methodologies
Unit Test
Make the codes efficient and make the single user and single thread faster
80% of the work
Volume/Load Test
Resolve contentions
Fine tune threading and system resources utilization
Do NOT start Load test before the application codes are fine tuned
Stress Test
Increase the number of concurrent users and transactions or threads
Test the maximum throughput of the hardware and software
Endurance Test
Test if the system is stable after the system is heavily used for an extended period
Test to Scale -- when you dont have the full size hardware
12 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Performance Testing Methodologies
Due to the data volume and logic complexity of the Oracle Retail systems, Performance testing
and tuning are very important for the success of the Oracle Retail implementation.
On the Enterprise Application side, RPM, RFM, RA, RMS/ReSA, and Allocation are the
applications that need significant performance tuning efforts
Performance testing and tuning efforts are very time consuming. For most of the customers, 20%
of the total man-dates are allocated to the performance testing and tuning efforts
Performance testing itself does not fix the issues. It is to detect the potential performance issue.
Tuning is the way to fix the issues. So allocate more time to the tuning efforts
Hardware has its limit of processing speed and scalability. Some performance issues may not
have resolution due to the limitation of the current technologies. In this case, change of business
process or the way to setup and use the application may be required for some issues. This is part
of the Oracle Retail Application Tuning Best Practice
13 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Performance Testing Methodologies
Performance tuning has 2 levels, Macro-level and Micro-level
Macro-level is to tune the system, database and application configurations and
parameters to increase the database and system efficiency and resolve the
contentions.
Micro-level is to tune the application code to make the application codes efficient.
Micro-level tuning fixes 80% of the performance issues and need 80% of the efforts
After application codes are well tuned, some database and system level contentions
will disappear. So always start the application tuning first with a typical database and
system configurations
The 2 tuning levels impact each other, but they can not completely replace the efforts
of the other level
Poor configurations make the Micro-level tuning difficult and the inefficient application
codes make the Macro-level tuning difficult
14 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Performance Testing Methodologies
Dedicated performance testing environment (at least dedicated application
server instance and dedicated physical database if sharing the same
hardware)
Same kind of servers and storage, and similar amount of memory as
Production, CPU count can be much less for the atomic tuning phase
The performance requirements and data volume should be pre-defined
The testing environment, users and data should be pre-tested end to end
for the target batches and online screens before the performance project
starts
Dedicated performance testing and tuning technical resources
The performance tuning team sit side by side
15 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Three Phases Performance Tuning Efforts
Before go-live
Data are created by scripts or data conversion, data are not 100% Production like
With foundation data basically. History data is limited, the performance tests before go-live can not detect all
of the potential performance issues, especially for RPM
6 to 12 months after go-live
RPM performance is very historical length sensitive due to the Roll Forward computation, Price Event
Inheritance and the sibling records for Rollup to the hierarchy level
Some performance issues start to show up 3 months after go-live, especially RPM
With real Production data
Should use physical copy of the Production database
Ongoing Performance Tuning
Performance tuning is an ongoing effort, especially for RPM
Performance will be getting stable along the ongoing tuning after 1 year
Before the Christmas busy season is a good time to fine tune the performance again
16 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Who need to involve the tuning efforts?
The tuning services provided by Oracle Retail are mainly for training purpose instead
of full tuning service
The performance DBA should be an application performance DBA in addition to a
system performance DBA. The should understand retail logic, application codes, the
SQL Execution Plan and database Wait Events
Application Engineers are needed to setup the testing data, execute the tests,
implement the code changes and do the functional tests.
Application Administrator to change application configurations and restart the
Application Servers
Because the performance tuning is a ongoing efforts, the customers performance
DBAs and application Administrators need to involve the tuning efforts deeply.
17 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
How to Create the Testing Data and Database?
Database foundation data must be production like in terms of data volume and data
profile
Database history data must be production like in terms of data volume and data
profile (especially for RPM)
Testing data volume and profile must be Production like
Testing scenarios must be production like
A heavily used UAT system with end to end tests every day is a good way to detect
potential performance issues before go-live
Physical Copy of the Production database is a good testing database after go-live
Database identical Block by Block with physical copy
18 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Generic Tuning
19 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Generic Tuning
20 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Application Settings Tuning
21 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Functional Considerations
22 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Data Purging
23 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
RMS Batch Configuration Tunings
The Threading and Commit Max Counter for RMS Batch
jobs are basically controlled by RESTART_CONTROL
Most of the RMS batch jobs are multi-threads capable
The UPDATE_ALLOW column is only for reference
Please refer the RMS Operation Guide for detail
If the Unit of Work is at low level (e.g. Item/Loc), start the
COMMIT_MAX_CTR setting with 10,000
If the Unit of Work is at higher level (e.g. Loc), start the
COMMIT_MAX_CTR setting with 1
24 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
RMS Batch Configuration Tunings
If the batch program is multi-threads capable
Start the number of threads to 1.2 x of CPU cores,
Fine tune the number of threads to the level that the DB servers
CPU resources are just or nearly fully utilized
The number of threads should be 1.5 to 2 times of No. of CPU
cores
If the batch job is running during the online window, control the
number of threads to leave adequate resources for online users
Both under threading and over threading will reduce the
throughput
25 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
RMS Batch Configuration Tuning
Balance the workload across the threads and start the
largest thread first.
This is to cut the batch tail.
Balance the workload across nodes with RAC cluster
The CPU Utilization Level Based load balancing does
not work well on batch job
The better load balancing algorithm is Round Robin.
26 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
RMS Batch Configuration Tunings
For partitioned tables, make the Partition key match the
threading key (or threading key to match the partition
key).
This is especially important for RAC cluster to reduce the Global
Cache related waits and Inter-connect traffic
27 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
RMS Batch Configuration Tunings
Gigabit network has adequate network bandwidth for
batch server to connect to DB server usually
The network latency is much more important for
performance than bandwidth
Direct network link (like Cross-over direct link) has the
least latency
If the customer has batch servers on different data
centers(e.g. D/R site), the local batch server should
connect to the local DB node normally
28 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
RMS Batch Configuration Tunings
RMS Pro*C batches can take the following options in
command line for performance tuning:
SQL_TRACE=8 (or 12) to turn on SQL trace
SORT_AREA_SIZE=[a number] to set the SORT_AREA_SIZE
HASH_AREA_SIZE=[a number] to set the HASH_AREA_SIZE
DB_FILE_MULTIBLOCK_READ_COUNT=[a valid number] to
change the session level parameter
Command line syntax: batch_name $UP SQL_TRACE=8
It is not easy to pass those parameters into UC4/Appwox
29 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
RPM Batch Configuration Setting
The threading for RPM Batch jobs is controlled by
RPM_BATCH_CONTROL
Start the LUW with 10,000 for medium to large Price
Events and fine tune LUW based on data profile
Small Price Events and/or long Time Line Sequence
should use smaller LUW.
E.g. the Item/Loc level Price Events use 1,000 LUW
30 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
RPM Batch Configuration Setting
PROGRAM_NAME NUM_THREADS THREAD_LUW_COUNT
------------------------------------------------------------ ----------- ---------------------------------------------------------
com.retek.rpm.batch.PriceEventExecutionBatch 16 5000
com.retek.rpm.batch.LocationMove.LocationMoveBatch 16 5000
com.retek.rpm.batch.LocationMove.PurgeLocationMovesBatch 1 5000
com.retek.rpm.batch.MerchExtract.MerchExtractKickOffBatch 16 5000
com.retek.rpm.batch.WorksheetAutoApproveBatch 16 5000
com.retek.rpm.batch.PromotionPurgeBatch 1 5000
com.retek.rpm.batch.NewItemLocBatch 16 5000
com.retek.rpm.batch.RegularPriceChangePublishBatch 1 5000
com.retek.rpm.batch.ClearancePriceChangePublishBatch 1 5000
com.retek.rpm.batch.PromotionPriceChangePublishBatch 1 5000
com.retek.rpm.batch.PriceEventExecutionRMSBatch 16 5000
com.retek.rpm.batch.PriceChangeAreaDifferentialBatch 16 5000
com.retek.rpm.app.bulkcc.service.BulkConflictCheckAppService 5000
com.retek.rpm.app.bulkcc.service.ChunkConflictCheckAppService 10000
com.retek.rpm.batch.refreshPos.RefreshPosDataBatch 16 5000
31 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
RPM Batch Configuration Settings
OAS Configurations
RPM conflict checking multi-threading is controlled by
orion-ejb-jar.xml in $ORACLE_HOME/j2ee/rpm_oc4j/application-
deployments/rpm13/rpm13
Review the following settings in orion-ejb-jar.xml
Start with the following thread settings and fine tune based on
system resource utilization
RPMTaskMDB RPMChunkMDB
MinListenerThreads = 0.5 X #CPU
MinListenerThreads = #CPU
MaxListenerThreads = 1 X #CPU
MaxListenerThreads = 1.5 X #CPU
Note: Large Price Events use smaller ratio
32 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
RPM Batch Configuration Setting
WebLogic
RPM conflict checking multi-threading is controlled by
weblogic-ejb-jar.xml in rpm14.jar under
${WLS_HOME}/user_projects/domains/base
domain/servers/<RPM_SERVER>/tmp/_WL
user/rpm14/wieeho/rpm14.jar
In the rpm14.jar, META-INF\weblogic-ejb-jar.xml
How To Set Up the Connection Factory and the
Threading Work Manager in Retail Price Management
(RPM) (Doc ID 1970823.1)
33 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
RPM Batch Configuration Setting
WebLogic
Review the following settings in weblogic-ejb-jar.xml
(DEFAULT is 16 THREADs):
Start with the following thread setting and fine tune based on
system resources utilization
For RPMTaskMDB and RPMChunkMDB
<weblogic-enterprise-bean>
<ejb-name>RPMTaskMDB</ejb-name>
<message-driven-descriptor>
<destination-jndi-name>jms/taskQueue</destination-jndi-name>
</message-driven-descriptor>
<reference-descriptor>
</reference-descriptor>
<dispatch-policy>threading_workmanager</dispatch-policy>
</weblogic-enterprise-bean>
34 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
App Server Configuration Parameters
35 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
RPM Logging & Tracing
Logging: Records batch timing step-by-step(useful for
current & historical analysis)
RPM_BATCH_LOG table to hold the logging information
RPM_V_BATCH_LOG view to output a readable format of the
logs
Tracing: Generate a trace with meaningful name without
using a tracing trigger. Just update a column in
RPM_BATCH_TRACE table for the batch you want to
trace
36 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
<Insert
Picture
Here>
SECTION 2
General rules:
Minimize workload make the application more efficient
Parallel processing multi-threading, parallel query
Balance workload make the workload balanced across
threads and nodes
Resolve contentions
SQL Tuning
Tune Execution Plan
38 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Why the Optimizer Picks up an Inefficient
Execution Plan
Without or inaccurate table and/or index statistics
Poorly written SQL that forces the Optimizer to pick up a
certain type of Execution Plan
Inadequate or improper indexing
Wrong hints
Unevenly distributed data
Bind Variable Peaking
39 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Database Maintenance
42 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Statistics on Global Temporary Tables
Easy Option
For the SQLs not picking up the right Execution Plan
with the Easy Option:
You may set table and index Stats using DBMS_STATS package
on GTT and retest
Note: You need to know the data profile very well to set the Stats manually.
The Set Stats may be good for some scenarios but not good for others.
43 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Statistics on Permanent Staging Tables
44 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Statistics on Permanent Staging Tables
45 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Statistics on Permanent Staging Tables
46 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Statistics on Staging Tables
Best Option
Delete the wrong statistics in the Staging tables
When application is running with a reasonable size transaction, Gather the
Tables and their Index Statistics when the data are still there (you may
want to kill the transaction (on Test system only) if there is no enough time
to gather the Stats before the transaction finishes). You can manually insert
the data into the staging tables if you know the data very well
You may set table and index Stats using DBMS_STATS package instead of
Gather Stats if you know the data profile very well
Test the performance with SQL Trace on
If the stats are good for performance, lock the statistics
47 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Statistics on Staging Tables
Best Option
Export the statistics to a table and transfer the Stats to Production
Database, export the stats table as a backup
If the statistics are over written for any reason, import the statistics
Dbms_stats.delete_table_stats(RMS,<TABLE_NAME>);
Dbms_stats.delete_index_stats(RMS,<INDEX_NAME>);
Dbms_stats.gather_table_stats(RMS,<TABLE_NAME>);
Dbms_stats.gather_index_stats(RMS,<INDEX_NAME>);
Dbms_stats.lock_table_stats(RMS,<TABLE_NAME>);
Note: You need to know the data profile very well to lock the Stats. The locked
Stats may be good for some scenarios but not good for others.
48 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Statistics on Staging Tables
Easy Option
If the application performance is optimal, leave the wrong statistics as it is
If there is a performance issue with a module, SQL trace it, find out the
Staging/Permanent tables used in this module, delete the wrong statistics in
the Staging tables and re-run it
If any of the modules are not happy with the staging tables without statistics,
apply the method defined into Best Option
Test the performance with SQL Trace ON
If the stats are good for performance, lock the statistics
If any of the Staging tables are analyzed again when they are empty or
unintended, repeat the right process again
49 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Staging Table and Index Maintenance
Permanent Staging Tables with frequent or large Inserts and Deletes should
be Truncated or Shrink Space Cascade to reset its high water mark, clean
up the indexes and clean up the left over data due to failed/killed sessions
Most of the Permanent Staging Tables should not have any data needed by
the application anymore if the transaction or batch finished, can be
truncated when there is no application running (e.g. after the online window
and before the batch)
Some Permanent Staging Tables have useful data therefore cannot be
truncated. For those tables, we can use:
ALTER TABLE TABLE_NAME SHRINK SPACE CASCADE;
Note: The table should be on ASSM tablespace and ROW MOVEMENT enabled
50 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Staging Table and Index Maintenance
51 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Staging Table and Index Maintenance
Staging/Working Table List in RPM database that may
be truncated (including but not limited to):
RPM_BULK_CC%
RPM_PE_CC_LOCK
RPM_%_WS
RPM_%WORKSPACE%
RPM_STAGE_ITEM_LOC_CLEAN
Please run the RPM PurgeBulkConflictCheckArtifacts batch job to clean up
the pending transaction before truncate the RPM working tables, just in
case there are any pending transactions!
Back up the data before truncating the working tables. The data can be for
trouble shooting purpose.
52 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Staging Table and Index Maintenance
53 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
<Insert
Picture
Here>
SECTION 3
54 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
SQL Tuning
56 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
SQL Tuning
57 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
SQL Tuning
58 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
How to Influence the Execution Plan?
59 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
SQL Plan Management
60 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
SQL Plan Management
On Testing DB
Set optimizer_capture_sql_plan_baselines=TRUE (Need larger SYSAUX TBS)
Set optimizer_use_sql_plan_baselines=TRUE (on both Test and Prod)
Run the applications
Identify, enable, accept and fix the SQL Plan with the good Execution Plan for the slow SQL
If there is no good SQL Plan generated, add hints to the SQL codes and compile the new codes,
run the application and capture the SQL Plan again
Disable SQL Plan with the wrong Execution Plans
Link the hinted Execution Plan to the non-hinted SQL Handle
Re-compile the original non-hinted codes and re-test.
Transfer the good SQL Plans to Production and review the Execution Plan and performance on
Production
61 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
SQL Plan Management
To Check the Baseline Records: DBA_SQL_PLAN_BASELINES
To Check The Execution Plan:
DBMS_XPLAN.DISPLAY_SQL_PLAN_BASELINE
62 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
SQL Plan Management
Link the hinted SQL Plan to the non-hinted SQL Handle
declare
l_op pls_integer;
begin
l_op := dbms_spm.load_plans_from_cursor_cache
(sql_id => 'cnazndd6j7d1v' -- sql_id of the hinted SQL
,plan_hash_value => 3724264953 -- plan hash value of the hinted Plan
,sql_handle => 'SQL_11f0e4472549338d' -- sql handle of the non-hinted SQL
);
end;
/
63 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Specify Hints
Can be on a:
simple SELECT, UPDATE, DELETE, or MERGE statement
parent statement or sub-query of a complex statement
part of a compound query or inline view
Immediately after the SELECT, UPDATE, DELETE, or
MERGE key words
For sub-query (or Union query) add hints after SELECT
key word in the sub-query
64 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Specify Hints
65 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Types of Hints
66 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Hints by Category
67 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Hints by Category
68 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Hints by Category
Hints for enabling optimizer features:
OPTIMIZER_FEATURES_ENABLE
Hints for online application upgrade:
CHANGE_DUPKEY_ERROR_INDEX,
IGNORE_ROW_ON_DUPKEY_INDEX,
RETRY_ON_ROW_CHANGE
Hints for Query Transformations: NO_QUERY_TRANSFORMATION,
USE_CONCAT, EXPAND, NO_EXPAND, REWRITE and
NO_REWRITE, MERGE and NO_MERGE,
STAR_TRANSFORMATION and NO_STAR_TRANSFORMATION,
FACT and NO_FACT, UNNEST and NO_UNNEST
69 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Hints by Category
70 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
SQL Trace
SQL Trace is the most useful tool for tuning
SQL Trace (level 1, 4, 8, 12) for session level (4=bind variables,
8=wait events, 12=both)
alter session set events '10046 trace name context forever, level 8';
alter session set TRACEFILE_IDENTIFIER=Your_Name';
Rms_batch username/password@db SQL_TRACE=8
Exec sys.DBMS_SYSTEM.SET_EV(SID, SERIAL#, 10046, 8, '');
TOAD or SQL Developer Click TOADs green button
How to get the SID and Serial#
select 'exec sys.dbms_system.set_ev('||sid||','||serial#||',10046,12,'||''''');' from
v$session where program like '%slsupld%';
71 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
SQL Trace
Formatting the raw trace
tkprof trace_file.trc output.txt sort=exeela,fchela explain=username/password@db sys=no
73 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Other Tools for SQL Tuning
Set timing ON
Set Autotrace ON
(OFF/TRACEONLY/EXPLAIN/STATISTICS)
Explain Plan
Use SQL Developer (or TOAD)
Command line
74 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
SQL Tuning
Explain plan set statement_id = 'SQL1' for SELECT /*+ INDEX(IM, PK_ITEM_MASTER) INDEX(ILS,
PK_ITEM_LOC_SOH) USE_NL(IM, ILS) LEADING(IM) */ ils.item, ils.loc, ils.stock_on_hand
FROM item_master im, item_loc_soh ils
WHERE ils.loc = 65 AND im.item = '4943902008' AND im.status='A' and im.item = ils.item;
75 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Application Design Tuning
Driving cursor design
Match the partitioning key
Minimize looping (by bulk/set processing)
Make the Work Unit size reasonable
Avoid contention (data and database block overlapping)
Multi-threading
Balanced threads
Adequate threads to make the server busy more than 1.5 x #CPU
Dynamic thread allocation vs. static thread allocation
Setup the number of threads to just fully utilize the system resources but
not over threading
76 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Application Design Tuning
Bulk processing
Define the loop to the optimal level
Location is a good looping key usually
Item/Loc is too low
Avoid Row by Row processing where possible
Avoid unnecessary processing (incremental computation)
Use Bind Variables where possible
Minimum network roundtrips and latency
77 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Application Profiling
78 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Application Profiling
79 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Database Instance Tuning
Database Performance Monitoring Tools
Automatic Workload Repository (AWR)
Taking a manual AWR snapshot (10g and beyond):
EXEC sys.dbms_workload_repository.create_snapshot;
Note: There is a hourly snapshot job by default database installation
Usually only tune the SGA, PGA and LOG buffer related parameters
and leave others as default
Oracle Optimizer is very sensitive to a few parameters
OPTIMIZER_*
DB_FILE_MULTIBLOCK_READ_COUNT
Tuning application code is our major task
80 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Important Sections in AWR Report
81 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Database Physical Tuning
82 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Database Physical Tuning
83 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
System Tuning
System Performance Monitoring Tools
Nmon (Aix and Linux, tracing mode and interactive mode)
Tracing mode to cover 24 hours: nmon f s 30 c 2880
Nmon_analyser.xls
Sar (all Unix)
Filemon (Aix)
Iostat (all Unix)
Netstat (all Unix)
Top (Solaris, Linux, HP UX)
Topas (Aix)
Vmstat (all Unix)
Glance/gpm (HP UX)
84 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
NMON CPU/IO Utilization Chart
85 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
SWAP/Paging Configuration
General rules
Adequate SWAP space to keep system running
Adequate memory, reasonable and efficient memory allocation to avoid
swapping
Swapping is worse than smaller SGA and PGA
86 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Storage Configurations
87 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Storage Configurations
88 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Exadata Smart Cache
To enable Flash_Cache on Exadata
alter|create table|index objectname
Storage (flash_cache { keep | default }); -- host level
alter|create table|index objectname
Storage (cell_flash_cache { keep | default }); -- storage cell level
To pre-cache the data or index keys
Select /*+ FULL(ILS) PARALLEL(ILS, 16) */ count(*) from ITEM_LOC_SOH ILS;
Select /*+ INDEX (ILS, PK_ITEM_LOC_SOH) */ count(*) from ITEM_LOC_SOH;
Select /*+ INDEX (ILS, PK_ITEM_LOC_SOH) INDEX_FFS (ILS, PK_ITEM_LOC_SOH) */ count(*) from
ITEM_LOC_SOH;
Exadata can cache 1 billion rows in 30 second. The cache is persistent even if the
database and ASM instances are restarted.
89 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Kernel Parameter Tuning
90 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Data Model Tuning for Customizations
Make the Data Model as close to your information needs as possible
Normalization vs. de-normalization
Size of N in the 1 N relationship
Fatness of the Parent and Child tables
Data assess pattern: Parent only or Parent + Child join
Consider making them in one table when,
N is very small
Parent table is slim and tall
Parent + Child often join together
91 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Links and Resources
Health Check: Maintenance Steps to Improve Retail Price
Management Application Performance (Doc ID 1387247.1)
To Setup The Connection Factory And The Threading Work Manager
In Retail Price Management (RPM) (Doc ID 1970823.1)
Oracle Retail Price Management Implementation Guidelines and
Checklist Release 13.2.6 and Release 14.0.x (Doc ID 1590869.1
How To Profile Java 6 Apps Using Visual VM and JRockit Mission
Control (Doc ID 1589626.1) 1589626.1
92 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
Links and Resources
93 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
94 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
95 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential
96 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Proprietary and Confidential