SlideShare uma empresa Scribd logo
1 de 33
Oracle Performance Tuning

Eric Geng
2/24/2011
Agenda

• Oracle Basics
• Performance Tuning Methods
• SQL Tuning
Oracle Architecture Overview


• Database
• Instance
• Multi-Processes, share
  memory based C program
• Interfaces
  • SQL, PL/SQL
  • JDBC, OCI, Pro*C etc

• Administration Interfaces
  • Sqlplus, RMAN
  • Enterprise Manger
Processes

• PMON – Process Monitor
• SMON – System Monitor
• DBWR – Data Base Writer
• LGWR – Log Writer
• CKPT – Checkpoint
• ARCH – Log Archive
Wait Event
• Over 800 wait events, classified to 10+ types.
• They are self-diagnostic instruments – lots of counts
  and timers.
• Events
  •   db file scattered read
  •   db file sequential read
  •   enqueue waits
  •   library cache latch/mutex
  •   log file sync
  •   buffer busy waits
  •   free buffer waits
  •   …
Dynamic Views
• System statistics
  • v$sys_time_model, v$sysstat

• Session statistics
  • v$session, v$sesstat

• Contention statistics
  • v$lock, v$latch

• SQL staticstics
  • v$sql, v$sql_plan, v$sql_plan_statistics_all
Statspack/AWR
• Capture dynamic statistics into snapshots, then
  summary database activities between two snapshots.
• Statspack(9i)
  •   External scripts and packages
  •   Store snapshots in own-created table
  •   DBMS_STATSPACK
  •   sp*.sql

• Automatic Workload Repository(10g)
  •   Built-in feature: scripts, packages, tables, automatic job
  •   Store snapshots in DBA_HIST_* tables
  •   DBMS_WORKLOAD_REPOSITORY
  •   awr*.sql
AWR report
Enterprise Manager
• ASH
 • Sampling in seconds, support real-time Performance view in OEM
 • Store in SGA, v$active_session_history
 • Can also generate reports

• ADDM
 • Automatic Database Diagnostic Monitor
 • Identify issues and give recommendations from snapshots

• SQL Tuning Advisor
 • Create sql profile for sql statement

• SQL Access Advisor
 • Advice on index etc for sql statement
Enterprise Manager
Top SQL
• Elapsed time
• Parse time
• Executions
• Buffer gets
• Physical reads
Basic terminology
• Anoptimizeris the part of the RDBMS responsible for
  determining the most efficient way for a SQL
  statement to access data
• An execution plan is the complete sequence of
  operations required to resolve a SQL statement (the
  combination of access paths and join methods). The
  in-memory structure of a execution plan also can be
  called a cursor.
• A join method determines how two tables will be
  joined together (only two tables can be joined
  together at a time)
Hard parse
• Syntax analysis
  • Analyze "text" of SQL query
  • Detect syntax errors
  • Create internal query representation

• Semantic Checking
  • Validate SQL statement
  • View analysis
  • Incorporate constraints, triggers, etc.

• Query Optimization
  • Modify query to improve performance (Query Rewrite)
  • Choose the most efficient "access plan" (Query Optimization)

• Plan Generation
Optimizer
• Optimizer mode
 • RULE, CHOOSE, FIRST_ROWS, ALL_ROWS

• RULE is not supported
• Cost Based Optimizer
 • Highly depends on statistics

• Init parameters can affect the CBO
 •   optimizer_mode
 •   optimizer_index_cost_adj
 •   optimizer_index_cache
 •   data_block_multiple_read_count
Execution Plan
• Explain plan for <query>
  • Select * from table(dbms_xplan.display);

• dbms_xplan.display
• dbms_xplan.display_cursor
• dbms_xplan.display_awr
• Query with /*+ gather_plan_statistics */
  • more details in v$sql_plan_statistics_all
  • dbms_xplan.display_cursor(null, null, ‘ALLSTAT LAST’)
  • useful to find out wrong estimation by optimizer
Execution Plan
Plan of ‘ALLSTATS’
How to read an execution plan
• Order
 • Inner -> outer
 • At same level, up -> down. Some operations are iterative.

• Rows
 • Estimated by optimizer. Often cause problem.

• Time
 • Estimated by optimizer. Very inaccurate.

• A-Rows | A-Time
 • Actual numbers. Collected by /*+ gather_plan_statistics */
Operations in execution plan
• TABLE ACCESS FULL
• INDEX RANGE SCAN / TABLE ACCESS BY INDEX ROWID
• NESTED LOOPS / HASH JOIN / MERGE JOIN
• MERGE JOIN CARTESIAN
• INLIST ITERATOR
• SORT
• AGGREGATE
• FILTER
SQL trace/tkprof
• Alter session set sql_trace = true (SQL*PLUS)
• Alter session set events '10046 trace name context
  forever, level 12‘
  •   Level 1 equals sql_trace=true
  •   Level 4 includes bind values
  •   Level 8 includes wait time statistics
  •   Level 12 includes both bind values and wait time stats.

• dbms_monitor.session_trace_enable(sid, serial#,
  waits, binds)
• Trace file is in USER_DUMP_DEST folder
• tkprof<trace_file><output_file>
SQL trace
TKPROF
Autotrace
• Set autotrace on/traceonly (SQL*PLUS)
• Besides the plan –
10053 trace (optimizer trace)
• Alter session set events ’10053 trace name context
  forever, level 1‘
SQL Tuning
• Common rules
 • Filter as early as possible and as much as possible
 • Join order is more significant than join method

• Methods
 •   Statistics
 •   Hints (sql profile / outline)
 •   Rewrite
 •   Index
 •   Schema
Statistics
• DBMS_STATS.GATHER_XXX_STATS
  • analyze table xxx compute/estimate statistics is deprecated
  • GATHER_STATS_JOB

• USER_TABLES
  • NUM_ROWS, BLOCKS, AVG_ROW_LEN

• USER_TAB_COL_STATISTICS
  • NUM_DISTINCT, NUM_NULLS, NUM_BUCKETS, DENSITY

• USER_INDEXES
  • NUM_ROWS, DISTINCT_KEYS, LEAF_BLOCKS, CLUSTERING_FACTOR,
    BLEVEL, AVG_LEAF_BLOCKS_PER_KEY

• USER_HISTOGRAM
  • ENDPOINT_NUMBER, ENDPOINT_VALUE
Hint /*+ */
• Join order
  • ORDERED, LEADING

• Join method
  • USE_NL, USE_HASH, USE_MERGE, STAR

• Query transformation
  • USE_CONCAT, NO_EXPAND, UNNEST, PUSH_SUBQ

• Index
  • INDEX, INDEX_JOIN, INDEX_COMBINE

• Stats
  • DYNAMIC_SAMPLING, CADINALITY, SELECTIVITY

• Sql Profile is a set of hints fundamentally
SQL rewrite
• In / exists
• Not in / not exists
• Correlated / non-correlated
• Join / SubQuery
Challenges for stable plan
• Volatile data
• Screw data / histograms / bind value peeking
• Data correlation
Application Tuning
• Avoid unnecessary query
 • Check logics
 • Cache

• Avoid to fetch too many rows
 • Pagination

• Avoid complex query
 • Material views
 • Denormalize

• Optimize locking
• Optimize indexes
OLTP applications
• Use connection pool
• Use bind variables (CURSOR_SHARING=FORCE?)
• Prefer OPTIMIZER_MODE=FIRST_ROW
• Enforce pagination
• Caution with any query which join too many tables
• Caution with any Full Table Scan or Fast Full Index Scan
  on large table
• Caution with any Sort, Aggregation, Hash Join, Merge
  Join, especially Merge Join Cartesian on large sets
Links
• oracle-l@freelists.org
• https://groups.google.com/forum/?pli=1#!forum/com
  p.databases.oracle.server
• http://tahiti.oracle.com/
• http://www.oaktable.net/
• http://blogs.oracle.com/optimizer/
• http://blog.tanelpoder.com/
• http://jonathanlewis.wordpress.com/
• http://kevinclosson.wordpress.com/
• http://structureddata.org/
• http://www.eygle.com/
Q&A




      Q&A

Mais conteúdo relacionado

Mais procurados

SQL Server Tuning to Improve Database Performance
SQL Server Tuning to Improve Database PerformanceSQL Server Tuning to Improve Database Performance
SQL Server Tuning to Improve Database PerformanceMark Ginnebaugh
 
Ash architecture and advanced usage rmoug2014
Ash architecture and advanced usage rmoug2014Ash architecture and advanced usage rmoug2014
Ash architecture and advanced usage rmoug2014John Beresniewicz
 
Database Performance Tuning
Database Performance Tuning Database Performance Tuning
Database Performance Tuning Arno Huetter
 
Oracle Performance Tuning Training | Oracle Performance Tuning
Oracle Performance Tuning Training | Oracle Performance TuningOracle Performance Tuning Training | Oracle Performance Tuning
Oracle Performance Tuning Training | Oracle Performance TuningOracleTrainings
 
Oracle Database Performance Tuning Concept
Oracle Database Performance Tuning ConceptOracle Database Performance Tuning Concept
Oracle Database Performance Tuning ConceptChien Chung Shen
 
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentalsDB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentalsJohn Beresniewicz
 
SQL Server Query Tuning Tips - Get it Right the First Time
SQL Server Query Tuning Tips - Get it Right the First TimeSQL Server Query Tuning Tips - Get it Right the First Time
SQL Server Query Tuning Tips - Get it Right the First TimeDean Richards
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuningngupt28
 
AWR DB performance Data Mining - Collaborate 2015
AWR DB performance Data Mining - Collaborate 2015AWR DB performance Data Mining - Collaborate 2015
AWR DB performance Data Mining - Collaborate 2015Yury Velikanov
 
Oracle Oracle Performance Tuning
Oracle Oracle Performance Tuning Oracle Oracle Performance Tuning
Oracle Oracle Performance Tuning Kernel Training
 
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And WhatPerformance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And Whatudaymoogala
 
Aioug vizag oracle12c_new_features
Aioug vizag oracle12c_new_featuresAioug vizag oracle12c_new_features
Aioug vizag oracle12c_new_featuresAiougVizagChapter
 
Oracle AWR Data mining
Oracle AWR Data miningOracle AWR Data mining
Oracle AWR Data miningYury Velikanov
 
SQL Server Performance Tuning Baseline
SQL Server Performance Tuning BaselineSQL Server Performance Tuning Baseline
SQL Server Performance Tuning Baseline► Supreme Mandal ◄
 
Awr1page - Sanity checking time instrumentation in AWR reports
Awr1page - Sanity checking time instrumentation in AWR reportsAwr1page - Sanity checking time instrumentation in AWR reports
Awr1page - Sanity checking time instrumentation in AWR reportsJohn Beresniewicz
 
Awr + 12c performance tuning
Awr + 12c performance tuningAwr + 12c performance tuning
Awr + 12c performance tuningAiougVizagChapter
 
Crack the complexity of oracle applications r12 workload v2
Crack the complexity of oracle applications r12 workload v2Crack the complexity of oracle applications r12 workload v2
Crack the complexity of oracle applications r12 workload v2Ajith Narayanan
 

Mais procurados (20)

SQL Server Tuning to Improve Database Performance
SQL Server Tuning to Improve Database PerformanceSQL Server Tuning to Improve Database Performance
SQL Server Tuning to Improve Database Performance
 
Ash architecture and advanced usage rmoug2014
Ash architecture and advanced usage rmoug2014Ash architecture and advanced usage rmoug2014
Ash architecture and advanced usage rmoug2014
 
Database Performance Tuning
Database Performance Tuning Database Performance Tuning
Database Performance Tuning
 
Oracle Performance Tuning Training | Oracle Performance Tuning
Oracle Performance Tuning Training | Oracle Performance TuningOracle Performance Tuning Training | Oracle Performance Tuning
Oracle Performance Tuning Training | Oracle Performance Tuning
 
Oracle Database Performance Tuning Concept
Oracle Database Performance Tuning ConceptOracle Database Performance Tuning Concept
Oracle Database Performance Tuning Concept
 
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentalsDB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
 
SQL Server Query Tuning Tips - Get it Right the First Time
SQL Server Query Tuning Tips - Get it Right the First TimeSQL Server Query Tuning Tips - Get it Right the First Time
SQL Server Query Tuning Tips - Get it Right the First Time
 
Awr1page OTW2018
Awr1page OTW2018Awr1page OTW2018
Awr1page OTW2018
 
Sql server performance tuning
Sql server performance tuningSql server performance tuning
Sql server performance tuning
 
AWR DB performance Data Mining - Collaborate 2015
AWR DB performance Data Mining - Collaborate 2015AWR DB performance Data Mining - Collaborate 2015
AWR DB performance Data Mining - Collaborate 2015
 
Oracle Oracle Performance Tuning
Oracle Oracle Performance Tuning Oracle Oracle Performance Tuning
Oracle Oracle Performance Tuning
 
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And WhatPerformance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
 
Aioug vizag oracle12c_new_features
Aioug vizag oracle12c_new_featuresAioug vizag oracle12c_new_features
Aioug vizag oracle12c_new_features
 
Oracle AWR Data mining
Oracle AWR Data miningOracle AWR Data mining
Oracle AWR Data mining
 
SQL Server Performance Tuning Baseline
SQL Server Performance Tuning BaselineSQL Server Performance Tuning Baseline
SQL Server Performance Tuning Baseline
 
Awr1page - Sanity checking time instrumentation in AWR reports
Awr1page - Sanity checking time instrumentation in AWR reportsAwr1page - Sanity checking time instrumentation in AWR reports
Awr1page - Sanity checking time instrumentation in AWR reports
 
Awr + 12c performance tuning
Awr + 12c performance tuningAwr + 12c performance tuning
Awr + 12c performance tuning
 
Analyzing awr report
Analyzing awr reportAnalyzing awr report
Analyzing awr report
 
Crack the complexity of oracle applications r12 workload v2
Crack the complexity of oracle applications r12 workload v2Crack the complexity of oracle applications r12 workload v2
Crack the complexity of oracle applications r12 workload v2
 
Ash and awr deep dive hotsos
Ash and awr deep dive hotsosAsh and awr deep dive hotsos
Ash and awr deep dive hotsos
 

Destaque

Oracle DB Performance Tuning Tips
Oracle DB Performance Tuning TipsOracle DB Performance Tuning Tips
Oracle DB Performance Tuning TipsAsanka Dilruk
 
Oracle 10g Performance: chapter 00 intro live_short
Oracle 10g Performance: chapter 00 intro live_shortOracle 10g Performance: chapter 00 intro live_short
Oracle 10g Performance: chapter 00 intro live_shortKyle Hailey
 
OOUG - Oracle Performance Tuning with AAS
OOUG - Oracle Performance Tuning with AASOOUG - Oracle Performance Tuning with AAS
OOUG - Oracle Performance Tuning with AASKyle Hailey
 
10g rac asm
10g rac asm10g rac asm
10g rac asmVictor
 
Hadoop Essential for Oracle Professionals
Hadoop Essential for Oracle ProfessionalsHadoop Essential for Oracle Professionals
Hadoop Essential for Oracle ProfessionalsChien Chung Shen
 
zero data loss recovery appliance
 zero data loss recovery appliance zero data loss recovery appliance
zero data loss recovery applianceJohan Louwers
 
Database As A Service: OEM + ODA (OOW 15 Presentation)
Database As A Service: OEM + ODA (OOW 15 Presentation)Database As A Service: OEM + ODA (OOW 15 Presentation)
Database As A Service: OEM + ODA (OOW 15 Presentation)Bobby Curtis
 
Step By Step Install Oracle 10g Rac Asm On Windows
Step By Step Install Oracle 10g Rac Asm On WindowsStep By Step Install Oracle 10g Rac Asm On Windows
Step By Step Install Oracle 10g Rac Asm On Windowsjstorm
 
Oracle Database Undo Segment Operation Concept
Oracle Database Undo Segment Operation ConceptOracle Database Undo Segment Operation Concept
Oracle Database Undo Segment Operation ConceptChien Chung Shen
 
Oracle Database Management Basic 1
Oracle Database Management Basic 1Oracle Database Management Basic 1
Oracle Database Management Basic 1Chien Chung Shen
 
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Aaron Shilo
 
Oracle Database SQL Tuning Concept
Oracle Database SQL Tuning ConceptOracle Database SQL Tuning Concept
Oracle Database SQL Tuning ConceptChien Chung Shen
 
Oracle cloud, private, public and hybrid
Oracle cloud, private, public and hybridOracle cloud, private, public and hybrid
Oracle cloud, private, public and hybridJohan Louwers
 
Oracle Index
Oracle IndexOracle Index
Oracle IndexJongwon
 
Oracle LOB Internals and Performance Tuning
Oracle LOB Internals and Performance TuningOracle LOB Internals and Performance Tuning
Oracle LOB Internals and Performance TuningTanel Poder
 
Database performance tuning and query optimization
Database performance tuning and query optimizationDatabase performance tuning and query optimization
Database performance tuning and query optimizationDhani Ahmad
 
Database Performance Tuning Introduction
Database  Performance Tuning IntroductionDatabase  Performance Tuning Introduction
Database Performance Tuning IntroductionMyOnlineITCourses
 
Performance tuning and optimization (ppt)
Performance tuning and optimization (ppt)Performance tuning and optimization (ppt)
Performance tuning and optimization (ppt)Harish Chand
 

Destaque (20)

Oracle DB Performance Tuning Tips
Oracle DB Performance Tuning TipsOracle DB Performance Tuning Tips
Oracle DB Performance Tuning Tips
 
Oracle 10g Performance: chapter 00 intro live_short
Oracle 10g Performance: chapter 00 intro live_shortOracle 10g Performance: chapter 00 intro live_short
Oracle 10g Performance: chapter 00 intro live_short
 
OOUG - Oracle Performance Tuning with AAS
OOUG - Oracle Performance Tuning with AASOOUG - Oracle Performance Tuning with AAS
OOUG - Oracle Performance Tuning with AAS
 
10g rac asm
10g rac asm10g rac asm
10g rac asm
 
Oracle SQL 1 Day Tutorial
Oracle SQL 1 Day TutorialOracle SQL 1 Day Tutorial
Oracle SQL 1 Day Tutorial
 
Understanding index
Understanding indexUnderstanding index
Understanding index
 
Hadoop Essential for Oracle Professionals
Hadoop Essential for Oracle ProfessionalsHadoop Essential for Oracle Professionals
Hadoop Essential for Oracle Professionals
 
zero data loss recovery appliance
 zero data loss recovery appliance zero data loss recovery appliance
zero data loss recovery appliance
 
Database As A Service: OEM + ODA (OOW 15 Presentation)
Database As A Service: OEM + ODA (OOW 15 Presentation)Database As A Service: OEM + ODA (OOW 15 Presentation)
Database As A Service: OEM + ODA (OOW 15 Presentation)
 
Step By Step Install Oracle 10g Rac Asm On Windows
Step By Step Install Oracle 10g Rac Asm On WindowsStep By Step Install Oracle 10g Rac Asm On Windows
Step By Step Install Oracle 10g Rac Asm On Windows
 
Oracle Database Undo Segment Operation Concept
Oracle Database Undo Segment Operation ConceptOracle Database Undo Segment Operation Concept
Oracle Database Undo Segment Operation Concept
 
Oracle Database Management Basic 1
Oracle Database Management Basic 1Oracle Database Management Basic 1
Oracle Database Management Basic 1
 
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
 
Oracle Database SQL Tuning Concept
Oracle Database SQL Tuning ConceptOracle Database SQL Tuning Concept
Oracle Database SQL Tuning Concept
 
Oracle cloud, private, public and hybrid
Oracle cloud, private, public and hybridOracle cloud, private, public and hybrid
Oracle cloud, private, public and hybrid
 
Oracle Index
Oracle IndexOracle Index
Oracle Index
 
Oracle LOB Internals and Performance Tuning
Oracle LOB Internals and Performance TuningOracle LOB Internals and Performance Tuning
Oracle LOB Internals and Performance Tuning
 
Database performance tuning and query optimization
Database performance tuning and query optimizationDatabase performance tuning and query optimization
Database performance tuning and query optimization
 
Database Performance Tuning Introduction
Database  Performance Tuning IntroductionDatabase  Performance Tuning Introduction
Database Performance Tuning Introduction
 
Performance tuning and optimization (ppt)
Performance tuning and optimization (ppt)Performance tuning and optimization (ppt)
Performance tuning and optimization (ppt)
 

Semelhante a Oracle performance tuning_sfsf

SQL Server 2014 Monitoring and Profiling
SQL Server 2014 Monitoring and ProfilingSQL Server 2014 Monitoring and Profiling
SQL Server 2014 Monitoring and ProfilingAbouzar Noori
 
SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1sqlserver.co.il
 
Data Integrity with SQL Database Ledger
Data Integrity with SQL Database LedgerData Integrity with SQL Database Ledger
Data Integrity with SQL Database LedgerGianluca Hotz
 
An Approach to Sql tuning - Part 1
An Approach to Sql tuning - Part 1An Approach to Sql tuning - Part 1
An Approach to Sql tuning - Part 1Navneet Upneja
 
Remote DBA Experts SQL Server 2008 New Features
Remote DBA Experts SQL Server 2008 New FeaturesRemote DBA Experts SQL Server 2008 New Features
Remote DBA Experts SQL Server 2008 New FeaturesRemote DBA Experts
 
SQL Server 2022 Programmability & Performance
SQL Server 2022 Programmability & PerformanceSQL Server 2022 Programmability & Performance
SQL Server 2022 Programmability & PerformanceGianluca Hotz
 
OTN tour 2015 AWR data mining
OTN tour 2015 AWR data miningOTN tour 2015 AWR data mining
OTN tour 2015 AWR data miningAndrejs Vorobjovs
 
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAsOracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAsZohar Elkayam
 
Empower my sql server administration with 5.7 instruments
Empower my sql server administration with 5.7 instrumentsEmpower my sql server administration with 5.7 instruments
Empower my sql server administration with 5.7 instrumentsMarco Tusa
 
SQL Server 2014 Mission Critical Performance - Level 300 Presentation
SQL Server 2014 Mission Critical Performance - Level 300 PresentationSQL Server 2014 Mission Critical Performance - Level 300 Presentation
SQL Server 2014 Mission Critical Performance - Level 300 PresentationDavid J Rosenthal
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cRonald Francisco Vargas Quesada
 
Java Developers, make the database work for you (NLJUG JFall 2010)
Java Developers, make the database work for you (NLJUG JFall 2010)Java Developers, make the database work for you (NLJUG JFall 2010)
Java Developers, make the database work for you (NLJUG JFall 2010)Lucas Jellema
 
MySQL Performance Schema in Action: the Complete Tutorial
MySQL Performance Schema in Action: the Complete TutorialMySQL Performance Schema in Action: the Complete Tutorial
MySQL Performance Schema in Action: the Complete TutorialSveta Smirnova
 
EM12c: Capacity Planning with OEM Metrics
EM12c: Capacity Planning with OEM MetricsEM12c: Capacity Planning with OEM Metrics
EM12c: Capacity Planning with OEM MetricsMaaz Anjum
 
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL ServerGeek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL ServerIDERA Software
 
MemSQL 201: Advanced Tips and Tricks Webcast
MemSQL 201: Advanced Tips and Tricks WebcastMemSQL 201: Advanced Tips and Tricks Webcast
MemSQL 201: Advanced Tips and Tricks WebcastSingleStore
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in ActionSveta Smirnova
 
Performance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Performance Scenario: Diagnosing and resolving sudden slow down on two node RACPerformance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Performance Scenario: Diagnosing and resolving sudden slow down on two node RACKristofferson A
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingSveta Smirnova
 

Semelhante a Oracle performance tuning_sfsf (20)

SQL Server 2014 Monitoring and Profiling
SQL Server 2014 Monitoring and ProfilingSQL Server 2014 Monitoring and Profiling
SQL Server 2014 Monitoring and Profiling
 
SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1SQL Explore 2012: P&T Part 1
SQL Explore 2012: P&T Part 1
 
Data Integrity with SQL Database Ledger
Data Integrity with SQL Database LedgerData Integrity with SQL Database Ledger
Data Integrity with SQL Database Ledger
 
An Approach to Sql tuning - Part 1
An Approach to Sql tuning - Part 1An Approach to Sql tuning - Part 1
An Approach to Sql tuning - Part 1
 
Remote DBA Experts SQL Server 2008 New Features
Remote DBA Experts SQL Server 2008 New FeaturesRemote DBA Experts SQL Server 2008 New Features
Remote DBA Experts SQL Server 2008 New Features
 
SQL Server 2022 Programmability & Performance
SQL Server 2022 Programmability & PerformanceSQL Server 2022 Programmability & Performance
SQL Server 2022 Programmability & Performance
 
OTN tour 2015 AWR data mining
OTN tour 2015 AWR data miningOTN tour 2015 AWR data mining
OTN tour 2015 AWR data mining
 
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAsOracle Database Performance Tuning Advanced Features and Best Practices for DBAs
Oracle Database Performance Tuning Advanced Features and Best Practices for DBAs
 
Empower my sql server administration with 5.7 instruments
Empower my sql server administration with 5.7 instrumentsEmpower my sql server administration with 5.7 instruments
Empower my sql server administration with 5.7 instruments
 
SQL Server 2014 Mission Critical Performance - Level 300 Presentation
SQL Server 2014 Mission Critical Performance - Level 300 PresentationSQL Server 2014 Mission Critical Performance - Level 300 Presentation
SQL Server 2014 Mission Critical Performance - Level 300 Presentation
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12c
 
Java Developers, make the database work for you (NLJUG JFall 2010)
Java Developers, make the database work for you (NLJUG JFall 2010)Java Developers, make the database work for you (NLJUG JFall 2010)
Java Developers, make the database work for you (NLJUG JFall 2010)
 
MySQL Performance Schema in Action: the Complete Tutorial
MySQL Performance Schema in Action: the Complete TutorialMySQL Performance Schema in Action: the Complete Tutorial
MySQL Performance Schema in Action: the Complete Tutorial
 
EM12c: Capacity Planning with OEM Metrics
EM12c: Capacity Planning with OEM MetricsEM12c: Capacity Planning with OEM Metrics
EM12c: Capacity Planning with OEM Metrics
 
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL ServerGeek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
 
MemSQL 201: Advanced Tips and Tricks Webcast
MemSQL 201: Advanced Tips and Tricks WebcastMemSQL 201: Advanced Tips and Tricks Webcast
MemSQL 201: Advanced Tips and Tricks Webcast
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in Action
 
Breaking data
Breaking dataBreaking data
Breaking data
 
Performance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Performance Scenario: Diagnosing and resolving sudden slow down on two node RACPerformance Scenario: Diagnosing and resolving sudden slow down on two node RAC
Performance Scenario: Diagnosing and resolving sudden slow down on two node RAC
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
 

Oracle performance tuning_sfsf

  • 2. Agenda • Oracle Basics • Performance Tuning Methods • SQL Tuning
  • 3. Oracle Architecture Overview • Database • Instance • Multi-Processes, share memory based C program • Interfaces • SQL, PL/SQL • JDBC, OCI, Pro*C etc • Administration Interfaces • Sqlplus, RMAN • Enterprise Manger
  • 4. Processes • PMON – Process Monitor • SMON – System Monitor • DBWR – Data Base Writer • LGWR – Log Writer • CKPT – Checkpoint • ARCH – Log Archive
  • 5. Wait Event • Over 800 wait events, classified to 10+ types. • They are self-diagnostic instruments – lots of counts and timers. • Events • db file scattered read • db file sequential read • enqueue waits • library cache latch/mutex • log file sync • buffer busy waits • free buffer waits • …
  • 6. Dynamic Views • System statistics • v$sys_time_model, v$sysstat • Session statistics • v$session, v$sesstat • Contention statistics • v$lock, v$latch • SQL staticstics • v$sql, v$sql_plan, v$sql_plan_statistics_all
  • 7. Statspack/AWR • Capture dynamic statistics into snapshots, then summary database activities between two snapshots. • Statspack(9i) • External scripts and packages • Store snapshots in own-created table • DBMS_STATSPACK • sp*.sql • Automatic Workload Repository(10g) • Built-in feature: scripts, packages, tables, automatic job • Store snapshots in DBA_HIST_* tables • DBMS_WORKLOAD_REPOSITORY • awr*.sql
  • 9. Enterprise Manager • ASH • Sampling in seconds, support real-time Performance view in OEM • Store in SGA, v$active_session_history • Can also generate reports • ADDM • Automatic Database Diagnostic Monitor • Identify issues and give recommendations from snapshots • SQL Tuning Advisor • Create sql profile for sql statement • SQL Access Advisor • Advice on index etc for sql statement
  • 11. Top SQL • Elapsed time • Parse time • Executions • Buffer gets • Physical reads
  • 12. Basic terminology • Anoptimizeris the part of the RDBMS responsible for determining the most efficient way for a SQL statement to access data • An execution plan is the complete sequence of operations required to resolve a SQL statement (the combination of access paths and join methods). The in-memory structure of a execution plan also can be called a cursor. • A join method determines how two tables will be joined together (only two tables can be joined together at a time)
  • 13. Hard parse • Syntax analysis • Analyze "text" of SQL query • Detect syntax errors • Create internal query representation • Semantic Checking • Validate SQL statement • View analysis • Incorporate constraints, triggers, etc. • Query Optimization • Modify query to improve performance (Query Rewrite) • Choose the most efficient "access plan" (Query Optimization) • Plan Generation
  • 14. Optimizer • Optimizer mode • RULE, CHOOSE, FIRST_ROWS, ALL_ROWS • RULE is not supported • Cost Based Optimizer • Highly depends on statistics • Init parameters can affect the CBO • optimizer_mode • optimizer_index_cost_adj • optimizer_index_cache • data_block_multiple_read_count
  • 15. Execution Plan • Explain plan for <query> • Select * from table(dbms_xplan.display); • dbms_xplan.display • dbms_xplan.display_cursor • dbms_xplan.display_awr • Query with /*+ gather_plan_statistics */ • more details in v$sql_plan_statistics_all • dbms_xplan.display_cursor(null, null, ‘ALLSTAT LAST’) • useful to find out wrong estimation by optimizer
  • 18. How to read an execution plan • Order • Inner -> outer • At same level, up -> down. Some operations are iterative. • Rows • Estimated by optimizer. Often cause problem. • Time • Estimated by optimizer. Very inaccurate. • A-Rows | A-Time • Actual numbers. Collected by /*+ gather_plan_statistics */
  • 19. Operations in execution plan • TABLE ACCESS FULL • INDEX RANGE SCAN / TABLE ACCESS BY INDEX ROWID • NESTED LOOPS / HASH JOIN / MERGE JOIN • MERGE JOIN CARTESIAN • INLIST ITERATOR • SORT • AGGREGATE • FILTER
  • 20. SQL trace/tkprof • Alter session set sql_trace = true (SQL*PLUS) • Alter session set events '10046 trace name context forever, level 12‘ • Level 1 equals sql_trace=true • Level 4 includes bind values • Level 8 includes wait time statistics • Level 12 includes both bind values and wait time stats. • dbms_monitor.session_trace_enable(sid, serial#, waits, binds) • Trace file is in USER_DUMP_DEST folder • tkprof<trace_file><output_file>
  • 23. Autotrace • Set autotrace on/traceonly (SQL*PLUS) • Besides the plan –
  • 24. 10053 trace (optimizer trace) • Alter session set events ’10053 trace name context forever, level 1‘
  • 25. SQL Tuning • Common rules • Filter as early as possible and as much as possible • Join order is more significant than join method • Methods • Statistics • Hints (sql profile / outline) • Rewrite • Index • Schema
  • 26. Statistics • DBMS_STATS.GATHER_XXX_STATS • analyze table xxx compute/estimate statistics is deprecated • GATHER_STATS_JOB • USER_TABLES • NUM_ROWS, BLOCKS, AVG_ROW_LEN • USER_TAB_COL_STATISTICS • NUM_DISTINCT, NUM_NULLS, NUM_BUCKETS, DENSITY • USER_INDEXES • NUM_ROWS, DISTINCT_KEYS, LEAF_BLOCKS, CLUSTERING_FACTOR, BLEVEL, AVG_LEAF_BLOCKS_PER_KEY • USER_HISTOGRAM • ENDPOINT_NUMBER, ENDPOINT_VALUE
  • 27. Hint /*+ */ • Join order • ORDERED, LEADING • Join method • USE_NL, USE_HASH, USE_MERGE, STAR • Query transformation • USE_CONCAT, NO_EXPAND, UNNEST, PUSH_SUBQ • Index • INDEX, INDEX_JOIN, INDEX_COMBINE • Stats • DYNAMIC_SAMPLING, CADINALITY, SELECTIVITY • Sql Profile is a set of hints fundamentally
  • 28. SQL rewrite • In / exists • Not in / not exists • Correlated / non-correlated • Join / SubQuery
  • 29. Challenges for stable plan • Volatile data • Screw data / histograms / bind value peeking • Data correlation
  • 30. Application Tuning • Avoid unnecessary query • Check logics • Cache • Avoid to fetch too many rows • Pagination • Avoid complex query • Material views • Denormalize • Optimize locking • Optimize indexes
  • 31. OLTP applications • Use connection pool • Use bind variables (CURSOR_SHARING=FORCE?) • Prefer OPTIMIZER_MODE=FIRST_ROW • Enforce pagination • Caution with any query which join too many tables • Caution with any Full Table Scan or Fast Full Index Scan on large table • Caution with any Sort, Aggregation, Hash Join, Merge Join, especially Merge Join Cartesian on large sets
  • 32. Links • oracle-l@freelists.org • https://groups.google.com/forum/?pli=1#!forum/com p.databases.oracle.server • http://tahiti.oracle.com/ • http://www.oaktable.net/ • http://blogs.oracle.com/optimizer/ • http://blog.tanelpoder.com/ • http://jonathanlewis.wordpress.com/ • http://kevinclosson.wordpress.com/ • http://structureddata.org/ • http://www.eygle.com/
  • 33. Q&A Q&A