SlideShare a Scribd company logo
1 of 25
OPTIMIZING APPLICATION
AND
DATABASE PERFORMANCE
1
ABOUT ME
• 15+ years of database-centric experience
• Oracle Certified Developer 2000
• Oracle DBA since 2002
-Oracle 8i,10g,11g RAC Expert , E-Business Suite DBA OCP
• Other Credentials: SCJP, SAP (FI/CO)
• Different Roles
- Developer, DBA, Analyst, SW Architect
• Trainer – Oracle Core, RAC Curriculum
• Current JD
- Senior Database Architect, Manage Oracle & SQL Server DBAs
• Blog
- dbmentors.blogspot.com
Inam Ullah Bukhari
2
AGENDA
• What is Optimization?
• Why you need it? Tuning goals
• How is it done/how it works?
• Optimization Areas
 Database Design (if it's not too late)
 Application
 Memory
 I/O
 Database Contention
3
WHAT/WHY - OPTIMIZATION?
• Achieving the best performance in shortest amount of time
• The use of system resources to perform work efficiently and
quickly to homogenize the performance of a database.
4
OPTIMIZATION AREAS
• Database Design (if it's not too late):
• Application
• Memory
• I/O
• Database Contention
5
DATABASE DESIGN
Poor Design => Poor Performance
Data Modeling
6
OPTIMIZING APPLICATION DESIGN
• Simplicity In Application Design
• Optimizing connection management
• Reducing the number of requests to the database using stored
procedures
• Reducing the number of requests to the database using
sequences
• Optimizing performance with schema De-Normalization
• Improving performance by sharing reusable code (Hard/Soft
Parsing)
• Reducing the number of requests to the database using
materialized views
• SQL Execution Efficiency - Avoiding dynamic SQL
7
DE-NORMALIZATION EXAMPLE
SET AUTOTRACE TRACEONLY
SELECT F.FIRSTNAME, F.LASTNAME, PK.DESCRIPTION AS PHONEKIND,
PA.WHENAVAILABLE AS AVAILABILITY, P.PHONENUMBER
FROM FRIEND F
INNER JOIN FRIEND_PHONE FP ON FP.FRIENDID = F.ID
INNER JOIN PHONE P ON P.ID = FP.PHONEID
INNER JOIN PHONEKIND PK ON PK.ID = P.PHONEKINDID
LEFT OUTER JOIN AVAILABILITY PA ON PA.ID = P.AVAILABILITYID
WHERE F.ID = 29912;
8
MATERIALIZED VIEW EXAMPLE
SELECT PROD_ID, SUM(AMOUNT_SOLD)
FROM SH.SALES GROUP BY PROD_ID;
CREATE MATERIALIZED VIEW
SH.MV_SALES_BY_PRODUCT
BUILD IMMEDIATE REFRESH ON COMMIT
ENABLE QUERY REWRITE AS
SELECT PROD_ID, SUM(AMOUNT_SOLD)
AS AMOUNT_SOLD FROM SH.SALES
GROUP BY PROD_ID;
9
AVOIDING DYNAMIC SQL EXAMPLE
SQL> declare
2 x number;
3 begin
4 for i in 1 .. 10
5 loop
6 execute immediate 'select count(*) from dual q1' into x;
7 select count(*) into x from dual q2;
8 end loop;
9 end;
10 /
-- sql_trace and tkprof
select count(*) from dual q1
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- --------
Parse 10 0.00 0.00 0 0 0 0
Execute 10 0.00 0.00 0 0 0 0
Fetch 10 0.00 0.01 0 10 40 10
------- ------ -------- ---------- ---------- ---------- ---------- --------
total 30 0.00 0.01 0 10 40 10
*******************************************************************************
SELECT COUNT(*) FROM DUAL q2
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- --------
Parse 1 0.00 0.00 0 0 0 0
Execute 10 0.00 0.00 0 0 0 0
Fetch 10 0.00 0.00 0 10 40 10
------- ------ -------- ---------- ---------- ---------- ---------- --------
total 21 0.00 0.00 0 10 40 10
10
- No compile time check
- No dependency mechanism (No clue)
- Overhead of doing dynamic stuff
OPTIMIZING STORAGE STRUCTURES
Chained Rows/Migrated Rows (using multiple block sizes)
ALTER SYSTEM SET db_16k_cache_size = 16m scope=both;
• Contention reduction
• Reduced row chaining
• Faster updates
• Reduced Pinging
• Less disk space waste
• Less RAM waste
• Minimize redo generation
• Faster scans
11
OPTIMIZING STORAGE STRUCTURES
• Using LOBs
- Separate Tablespace
- Cache,NoCache,CacheReads
• Indexing the correct way
- B-tree
- Reverse Key
- Function Based
- Bitmap
- Analyze
- Compress
• Using partitioning
- Partition Pruning
- Massive DML Operations in parallel
12
OPTIMIZING SQL CODE
PROCEDURE PNOBIND(CUSTID IN sh.customers.cust_id%TYPE)
IS
BEGIN
DECLARE aRow sh.customers%ROWTYPE;
l_stmt VARCHAR2(2000);
BEGIN
l_stmt := 'SELECT * FROM sh.customers s WHERE s.cust_id=‘ || TO_CHAR (CUSTID);
EXECUTE IMMEDIATE l_stmt INTO aRow;
…..
END ;
PROCEDURE PBIND(CUSTID IN sh.customers.cust_id%TYPE) IS
BEGIN
DECLARE aRow sh.customers%ROWTYPE;
l_stmt VARCHAR2(2000);
BEGIN
l_stmt := 'SELECT * FROM sh.customers s WHERE s.cust_id =:p_cust_id';
EXECUTE IMMEDIATE l_stmt INTO aRow USING CUSTID;
…..
END;
PROCEDURE TEST_BIND_STATIC(CUSTID IN sh.customers.cust_id%TYPE) IS
BEGIN
DECLARE aRow sh.customers%ROWTYPE;
BEGIN
SELECT * INTO aROW FROM sh.customers s WHERE s.cust_id =CUSTID;
…..
END;
50k Runs
• Bind Variables
• Concurrency
and scalability
13
OPTIMIZING SQL CODE
Avoiding full table scans (many I/O operations/buffer cache flush)
FTS - Small Tables
The High-Water Mark
14
SQL OPTIMIZATION
Arrays and Bulk operations
15
IMPROVING THE ORACLE OPTIMIZER
• Optimizer Hints
/*+ optimizer_features_enable('11.1.0.6') */
• Statistics & Histogram
• Stored Outlines
16
OTHER OPTIMIZATIONS
Caching results - client-side result cache
ALTER SYSTEM SET CLIENT_RESULT_CACHE_SIZE=5M SCOPE=SPFILE;
ALTER SESSION SET RESULT_CACHE_MODE = FORCE
ALTER TABLE CUSTOMERS RESULT_CACHE (MODE FORCE);
SELECT /*+ result_cache */ COUNTRY_NAME, CUST_LAST_NAME, COUNT(*) ……..
Enabling parallel SQL
SELECT /*+ PARALLEL (S, 2) */ S.PROD_ID, S.CUST_ID, S.TIME_ID FROM SH.SALES S
ORDER BY S.AMOUNT_SOLD DESC;
Direct path inserting
/*+ APPEND */ hint for INSERT
17
OTHER OPTIMIZATIONS
18
OTHER OPTIMIZATIONS
Using create table as select – CTAS
Avoid Over Indexing
19
OTHER OPTIMIZATIONS
Avoid unnecessary triggers – use virtual columns where possible
20
OTHER OPTIMIZATIONS
SQL Loader & External Tables
21
OPTIMIZING MEMORY
• Avoid Operating System paging/Swapping
• AMM – Don’t use with hugepages and MTS
• Tuning the Library Cache (Hits & Misses)
22
OPTIMIZING MEMORY
Dictionary Cache
- Reduce DDL activities
- Use the CACHE option for Sequences
Program Global Area and the User Global Area
- OPEN_CURSORS
- SESSION_CACHED_CURSORS
- CURSOR_SHARING
Buffer Cache
- configure multiple Buffer Pools
23
OPTIMIZING I/O
• Redologs on disks without other activities
• Redo logs and Archived redo logs on separate disks
• Heavily accessed files on separate disk
• Distribute the data files based on disk controller allocation
• Separate disks for data that is not related to the database
• Striping objects across multiple disks
• Distribute table and related indexes on different disks
24
OPTIMIZING CONTENTION
Detecting and preventing lock contention
- V$LOCK, V$ENQUEUE_LOCK, V$ENQUEUE_LOCK,
DBA_WAITERS, DBA_BLOCKERS
Latches – Is there any Tuning?
- V$SYSTEM_EVENT
25

More Related Content

What's hot

Understanding MySQL Performance through Benchmarking
Understanding MySQL Performance through BenchmarkingUnderstanding MySQL Performance through Benchmarking
Understanding MySQL Performance through BenchmarkingLaine Campbell
 
Oracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmastersOracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmastersKyle Hailey
 
Oracle sql high performance tuning
Oracle sql high performance tuningOracle sql high performance tuning
Oracle sql high performance tuningGuy Harrison
 
Streaming replication in PostgreSQL
Streaming replication in PostgreSQLStreaming replication in PostgreSQL
Streaming replication in PostgreSQLAshnikbiz
 
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
 
AWR Ambiguity: Performance reasoning when the numbers don't add up
AWR Ambiguity: Performance reasoning when the numbers don't add upAWR Ambiguity: Performance reasoning when the numbers don't add up
AWR Ambiguity: Performance reasoning when the numbers don't add upJohn Beresniewicz
 
PostgreSQL 9.6 Performance-Scalability Improvements
PostgreSQL 9.6 Performance-Scalability ImprovementsPostgreSQL 9.6 Performance-Scalability Improvements
PostgreSQL 9.6 Performance-Scalability ImprovementsPGConf APAC
 
Dan Hotka's Top 10 Oracle 12c New Features
Dan Hotka's Top 10 Oracle 12c New FeaturesDan Hotka's Top 10 Oracle 12c New Features
Dan Hotka's Top 10 Oracle 12c New FeaturesEmbarcadero Technologies
 
Direct SGA access without SQL
Direct SGA access without SQLDirect SGA access without SQL
Direct SGA access without SQLKyle Hailey
 
How to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with GaleraHow to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with GaleraSveta Smirnova
 
PGPool-II Load testing
PGPool-II Load testingPGPool-II Load testing
PGPool-II Load testingEDB
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingSveta Smirnova
 
Oracle database 12.2 new features
Oracle database 12.2 new featuresOracle database 12.2 new features
Oracle database 12.2 new featuresAlfredo Krieg
 
Oracle Database SQL Tuning Concept
Oracle Database SQL Tuning ConceptOracle Database SQL Tuning Concept
Oracle Database SQL Tuning ConceptChien Chung Shen
 
Oracle Database 12.1.0.2 New Performance Features
Oracle Database 12.1.0.2 New Performance FeaturesOracle Database 12.1.0.2 New Performance Features
Oracle Database 12.1.0.2 New Performance FeaturesChristian Antognini
 
VirtaThon 2011 - Mining the AWR
VirtaThon 2011 - Mining the AWRVirtaThon 2011 - Mining the AWR
VirtaThon 2011 - Mining the AWRKristofferson A
 
Toro DB- Open-source, MongoDB-compatible database, built on top of PostgreSQL
Toro DB- Open-source, MongoDB-compatible database,  built on top of PostgreSQLToro DB- Open-source, MongoDB-compatible database,  built on top of PostgreSQL
Toro DB- Open-source, MongoDB-compatible database, built on top of PostgreSQLInMobi Technology
 

What's hot (20)

Understanding MySQL Performance through Benchmarking
Understanding MySQL Performance through BenchmarkingUnderstanding MySQL Performance through Benchmarking
Understanding MySQL Performance through Benchmarking
 
Case Studies on PostgreSQL
Case Studies on PostgreSQLCase Studies on PostgreSQL
Case Studies on PostgreSQL
 
Oracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmastersOracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmasters
 
Oracle sql high performance tuning
Oracle sql high performance tuningOracle sql high performance tuning
Oracle sql high performance tuning
 
Streaming replication in PostgreSQL
Streaming replication in PostgreSQLStreaming replication in PostgreSQL
Streaming replication in PostgreSQL
 
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
 
AWR Ambiguity: Performance reasoning when the numbers don't add up
AWR Ambiguity: Performance reasoning when the numbers don't add upAWR Ambiguity: Performance reasoning when the numbers don't add up
AWR Ambiguity: Performance reasoning when the numbers don't add up
 
PostgreSQL 9.6 Performance-Scalability Improvements
PostgreSQL 9.6 Performance-Scalability ImprovementsPostgreSQL 9.6 Performance-Scalability Improvements
PostgreSQL 9.6 Performance-Scalability Improvements
 
Dan Hotka's Top 10 Oracle 12c New Features
Dan Hotka's Top 10 Oracle 12c New FeaturesDan Hotka's Top 10 Oracle 12c New Features
Dan Hotka's Top 10 Oracle 12c New Features
 
Direct SGA access without SQL
Direct SGA access without SQLDirect SGA access without SQL
Direct SGA access without SQL
 
How to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with GaleraHow to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with Galera
 
PGPool-II Load testing
PGPool-II Load testingPGPool-II Load testing
PGPool-II Load testing
 
Awr1page OTW2018
Awr1page OTW2018Awr1page OTW2018
Awr1page OTW2018
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
 
Oracle database 12.2 new features
Oracle database 12.2 new featuresOracle database 12.2 new features
Oracle database 12.2 new features
 
ProxySQL para mysql
ProxySQL para mysqlProxySQL para mysql
ProxySQL para mysql
 
Oracle Database SQL Tuning Concept
Oracle Database SQL Tuning ConceptOracle Database SQL Tuning Concept
Oracle Database SQL Tuning Concept
 
Oracle Database 12.1.0.2 New Performance Features
Oracle Database 12.1.0.2 New Performance FeaturesOracle Database 12.1.0.2 New Performance Features
Oracle Database 12.1.0.2 New Performance Features
 
VirtaThon 2011 - Mining the AWR
VirtaThon 2011 - Mining the AWRVirtaThon 2011 - Mining the AWR
VirtaThon 2011 - Mining the AWR
 
Toro DB- Open-source, MongoDB-compatible database, built on top of PostgreSQL
Toro DB- Open-source, MongoDB-compatible database,  built on top of PostgreSQLToro DB- Open-source, MongoDB-compatible database,  built on top of PostgreSQL
Toro DB- Open-source, MongoDB-compatible database, built on top of PostgreSQL
 

Similar to Optimizing applications and database performance

Configuring Sage 500 for Performance
Configuring Sage 500 for PerformanceConfiguring Sage 500 for Performance
Configuring Sage 500 for PerformanceRKLeSolutions
 
Exploring plsql new features best practices september 2013
Exploring plsql new features best practices   september 2013Exploring plsql new features best practices   september 2013
Exploring plsql new features best practices september 2013Andrejs Vorobjovs
 
Analyzing SQL Traces generated by EVENT 10046.pptx
Analyzing SQL Traces generated by EVENT 10046.pptxAnalyzing SQL Traces generated by EVENT 10046.pptx
Analyzing SQL Traces generated by EVENT 10046.pptxssuserbad8d3
 
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...Nelson Calero
 
My Experience Using Oracle SQL Plan Baselines 11g/12c
My Experience Using Oracle SQL Plan Baselines 11g/12cMy Experience Using Oracle SQL Plan Baselines 11g/12c
My Experience Using Oracle SQL Plan Baselines 11g/12cNelson Calero
 
LVOUG meetup #4 - Case Study 10g to 11g
LVOUG meetup #4 - Case Study 10g to 11gLVOUG meetup #4 - Case Study 10g to 11g
LVOUG meetup #4 - Case Study 10g to 11gMaris Elsins
 
DB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource ManagerDB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource ManagerAndrejs Vorobjovs
 
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
 
Oracle Database In-Memory Option in Action
Oracle Database In-Memory Option in ActionOracle Database In-Memory Option in Action
Oracle Database In-Memory Option in ActionTanel Poder
 
In Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry OsborneIn Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry OsborneEnkitec
 
Sql and PL/SQL Best Practices I
Sql and PL/SQL Best Practices ISql and PL/SQL Best Practices I
Sql and PL/SQL Best Practices ICarlos Oliveira
 
Embarcadero In Search of Plan Stability Part 1 Webinar Slides
Embarcadero In Search of Plan Stability Part 1 Webinar SlidesEmbarcadero In Search of Plan Stability Part 1 Webinar Slides
Embarcadero In Search of Plan Stability Part 1 Webinar SlidesEmbarcadero Technologies
 
Top 10 tips for Oracle performance
Top 10 tips for Oracle performanceTop 10 tips for Oracle performance
Top 10 tips for Oracle performanceGuy Harrison
 
Adapting and adopting spm v04
Adapting and adopting spm v04Adapting and adopting spm v04
Adapting and adopting spm v04Carlos Sierra
 
M|18 Migrating from Oracle and Handling PL/SQL Stored Procedures
M|18 Migrating from Oracle and Handling PL/SQL Stored ProceduresM|18 Migrating from Oracle and Handling PL/SQL Stored Procedures
M|18 Migrating from Oracle and Handling PL/SQL Stored ProceduresMariaDB plc
 
Migrations from PLSQL and Transact-SQL - m18
Migrations from PLSQL and Transact-SQL - m18Migrations from PLSQL and Transact-SQL - m18
Migrations from PLSQL and Transact-SQL - m18Wagner Bianchi
 
NOCOUG_201311_Fine_Tuning_Execution_Plans.pdf
NOCOUG_201311_Fine_Tuning_Execution_Plans.pdfNOCOUG_201311_Fine_Tuning_Execution_Plans.pdf
NOCOUG_201311_Fine_Tuning_Execution_Plans.pdfcookie1969
 
ebs-performance-tuning-part-1-470542.pdf
ebs-performance-tuning-part-1-470542.pdfebs-performance-tuning-part-1-470542.pdf
ebs-performance-tuning-part-1-470542.pdfElboulmaniMohamed
 

Similar to Optimizing applications and database performance (20)

Configuring Sage 500 for Performance
Configuring Sage 500 for PerformanceConfiguring Sage 500 for Performance
Configuring Sage 500 for Performance
 
Oracle SQL Tuning
Oracle SQL TuningOracle SQL Tuning
Oracle SQL Tuning
 
Exploring plsql new features best practices september 2013
Exploring plsql new features best practices   september 2013Exploring plsql new features best practices   september 2013
Exploring plsql new features best practices september 2013
 
Analyzing SQL Traces generated by EVENT 10046.pptx
Analyzing SQL Traces generated by EVENT 10046.pptxAnalyzing SQL Traces generated by EVENT 10046.pptx
Analyzing SQL Traces generated by EVENT 10046.pptx
 
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...
Evolution of Performance Management: Oracle 12c adaptive optimizations - ukou...
 
Oracle SQL Tuning
Oracle SQL TuningOracle SQL Tuning
Oracle SQL Tuning
 
My Experience Using Oracle SQL Plan Baselines 11g/12c
My Experience Using Oracle SQL Plan Baselines 11g/12cMy Experience Using Oracle SQL Plan Baselines 11g/12c
My Experience Using Oracle SQL Plan Baselines 11g/12c
 
LVOUG meetup #4 - Case Study 10g to 11g
LVOUG meetup #4 - Case Study 10g to 11gLVOUG meetup #4 - Case Study 10g to 11g
LVOUG meetup #4 - Case Study 10g to 11g
 
DB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource ManagerDB12c: All You Need to Know About the Resource Manager
DB12c: All You Need to Know About the Resource Manager
 
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
 
Oracle Database In-Memory Option in Action
Oracle Database In-Memory Option in ActionOracle Database In-Memory Option in Action
Oracle Database In-Memory Option in Action
 
In Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry OsborneIn Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry Osborne
 
Sql and PL/SQL Best Practices I
Sql and PL/SQL Best Practices ISql and PL/SQL Best Practices I
Sql and PL/SQL Best Practices I
 
Embarcadero In Search of Plan Stability Part 1 Webinar Slides
Embarcadero In Search of Plan Stability Part 1 Webinar SlidesEmbarcadero In Search of Plan Stability Part 1 Webinar Slides
Embarcadero In Search of Plan Stability Part 1 Webinar Slides
 
Top 10 tips for Oracle performance
Top 10 tips for Oracle performanceTop 10 tips for Oracle performance
Top 10 tips for Oracle performance
 
Adapting and adopting spm v04
Adapting and adopting spm v04Adapting and adopting spm v04
Adapting and adopting spm v04
 
M|18 Migrating from Oracle and Handling PL/SQL Stored Procedures
M|18 Migrating from Oracle and Handling PL/SQL Stored ProceduresM|18 Migrating from Oracle and Handling PL/SQL Stored Procedures
M|18 Migrating from Oracle and Handling PL/SQL Stored Procedures
 
Migrations from PLSQL and Transact-SQL - m18
Migrations from PLSQL and Transact-SQL - m18Migrations from PLSQL and Transact-SQL - m18
Migrations from PLSQL and Transact-SQL - m18
 
NOCOUG_201311_Fine_Tuning_Execution_Plans.pdf
NOCOUG_201311_Fine_Tuning_Execution_Plans.pdfNOCOUG_201311_Fine_Tuning_Execution_Plans.pdf
NOCOUG_201311_Fine_Tuning_Execution_Plans.pdf
 
ebs-performance-tuning-part-1-470542.pdf
ebs-performance-tuning-part-1-470542.pdfebs-performance-tuning-part-1-470542.pdf
ebs-performance-tuning-part-1-470542.pdf
 

Recently uploaded

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 

Recently uploaded (20)

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 

Optimizing applications and database performance

  • 2. ABOUT ME • 15+ years of database-centric experience • Oracle Certified Developer 2000 • Oracle DBA since 2002 -Oracle 8i,10g,11g RAC Expert , E-Business Suite DBA OCP • Other Credentials: SCJP, SAP (FI/CO) • Different Roles - Developer, DBA, Analyst, SW Architect • Trainer – Oracle Core, RAC Curriculum • Current JD - Senior Database Architect, Manage Oracle & SQL Server DBAs • Blog - dbmentors.blogspot.com Inam Ullah Bukhari 2
  • 3. AGENDA • What is Optimization? • Why you need it? Tuning goals • How is it done/how it works? • Optimization Areas  Database Design (if it's not too late)  Application  Memory  I/O  Database Contention 3
  • 4. WHAT/WHY - OPTIMIZATION? • Achieving the best performance in shortest amount of time • The use of system resources to perform work efficiently and quickly to homogenize the performance of a database. 4
  • 5. OPTIMIZATION AREAS • Database Design (if it's not too late): • Application • Memory • I/O • Database Contention 5
  • 6. DATABASE DESIGN Poor Design => Poor Performance Data Modeling 6
  • 7. OPTIMIZING APPLICATION DESIGN • Simplicity In Application Design • Optimizing connection management • Reducing the number of requests to the database using stored procedures • Reducing the number of requests to the database using sequences • Optimizing performance with schema De-Normalization • Improving performance by sharing reusable code (Hard/Soft Parsing) • Reducing the number of requests to the database using materialized views • SQL Execution Efficiency - Avoiding dynamic SQL 7
  • 8. DE-NORMALIZATION EXAMPLE SET AUTOTRACE TRACEONLY SELECT F.FIRSTNAME, F.LASTNAME, PK.DESCRIPTION AS PHONEKIND, PA.WHENAVAILABLE AS AVAILABILITY, P.PHONENUMBER FROM FRIEND F INNER JOIN FRIEND_PHONE FP ON FP.FRIENDID = F.ID INNER JOIN PHONE P ON P.ID = FP.PHONEID INNER JOIN PHONEKIND PK ON PK.ID = P.PHONEKINDID LEFT OUTER JOIN AVAILABILITY PA ON PA.ID = P.AVAILABILITYID WHERE F.ID = 29912; 8
  • 9. MATERIALIZED VIEW EXAMPLE SELECT PROD_ID, SUM(AMOUNT_SOLD) FROM SH.SALES GROUP BY PROD_ID; CREATE MATERIALIZED VIEW SH.MV_SALES_BY_PRODUCT BUILD IMMEDIATE REFRESH ON COMMIT ENABLE QUERY REWRITE AS SELECT PROD_ID, SUM(AMOUNT_SOLD) AS AMOUNT_SOLD FROM SH.SALES GROUP BY PROD_ID; 9
  • 10. AVOIDING DYNAMIC SQL EXAMPLE SQL> declare 2 x number; 3 begin 4 for i in 1 .. 10 5 loop 6 execute immediate 'select count(*) from dual q1' into x; 7 select count(*) into x from dual q2; 8 end loop; 9 end; 10 / -- sql_trace and tkprof select count(*) from dual q1 call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- -------- Parse 10 0.00 0.00 0 0 0 0 Execute 10 0.00 0.00 0 0 0 0 Fetch 10 0.00 0.01 0 10 40 10 ------- ------ -------- ---------- ---------- ---------- ---------- -------- total 30 0.00 0.01 0 10 40 10 ******************************************************************************* SELECT COUNT(*) FROM DUAL q2 call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- -------- Parse 1 0.00 0.00 0 0 0 0 Execute 10 0.00 0.00 0 0 0 0 Fetch 10 0.00 0.00 0 10 40 10 ------- ------ -------- ---------- ---------- ---------- ---------- -------- total 21 0.00 0.00 0 10 40 10 10 - No compile time check - No dependency mechanism (No clue) - Overhead of doing dynamic stuff
  • 11. OPTIMIZING STORAGE STRUCTURES Chained Rows/Migrated Rows (using multiple block sizes) ALTER SYSTEM SET db_16k_cache_size = 16m scope=both; • Contention reduction • Reduced row chaining • Faster updates • Reduced Pinging • Less disk space waste • Less RAM waste • Minimize redo generation • Faster scans 11
  • 12. OPTIMIZING STORAGE STRUCTURES • Using LOBs - Separate Tablespace - Cache,NoCache,CacheReads • Indexing the correct way - B-tree - Reverse Key - Function Based - Bitmap - Analyze - Compress • Using partitioning - Partition Pruning - Massive DML Operations in parallel 12
  • 13. OPTIMIZING SQL CODE PROCEDURE PNOBIND(CUSTID IN sh.customers.cust_id%TYPE) IS BEGIN DECLARE aRow sh.customers%ROWTYPE; l_stmt VARCHAR2(2000); BEGIN l_stmt := 'SELECT * FROM sh.customers s WHERE s.cust_id=‘ || TO_CHAR (CUSTID); EXECUTE IMMEDIATE l_stmt INTO aRow; ….. END ; PROCEDURE PBIND(CUSTID IN sh.customers.cust_id%TYPE) IS BEGIN DECLARE aRow sh.customers%ROWTYPE; l_stmt VARCHAR2(2000); BEGIN l_stmt := 'SELECT * FROM sh.customers s WHERE s.cust_id =:p_cust_id'; EXECUTE IMMEDIATE l_stmt INTO aRow USING CUSTID; ….. END; PROCEDURE TEST_BIND_STATIC(CUSTID IN sh.customers.cust_id%TYPE) IS BEGIN DECLARE aRow sh.customers%ROWTYPE; BEGIN SELECT * INTO aROW FROM sh.customers s WHERE s.cust_id =CUSTID; ….. END; 50k Runs • Bind Variables • Concurrency and scalability 13
  • 14. OPTIMIZING SQL CODE Avoiding full table scans (many I/O operations/buffer cache flush) FTS - Small Tables The High-Water Mark 14
  • 15. SQL OPTIMIZATION Arrays and Bulk operations 15
  • 16. IMPROVING THE ORACLE OPTIMIZER • Optimizer Hints /*+ optimizer_features_enable('11.1.0.6') */ • Statistics & Histogram • Stored Outlines 16
  • 17. OTHER OPTIMIZATIONS Caching results - client-side result cache ALTER SYSTEM SET CLIENT_RESULT_CACHE_SIZE=5M SCOPE=SPFILE; ALTER SESSION SET RESULT_CACHE_MODE = FORCE ALTER TABLE CUSTOMERS RESULT_CACHE (MODE FORCE); SELECT /*+ result_cache */ COUNTRY_NAME, CUST_LAST_NAME, COUNT(*) …….. Enabling parallel SQL SELECT /*+ PARALLEL (S, 2) */ S.PROD_ID, S.CUST_ID, S.TIME_ID FROM SH.SALES S ORDER BY S.AMOUNT_SOLD DESC; Direct path inserting /*+ APPEND */ hint for INSERT 17
  • 19. OTHER OPTIMIZATIONS Using create table as select – CTAS Avoid Over Indexing 19
  • 20. OTHER OPTIMIZATIONS Avoid unnecessary triggers – use virtual columns where possible 20
  • 21. OTHER OPTIMIZATIONS SQL Loader & External Tables 21
  • 22. OPTIMIZING MEMORY • Avoid Operating System paging/Swapping • AMM – Don’t use with hugepages and MTS • Tuning the Library Cache (Hits & Misses) 22
  • 23. OPTIMIZING MEMORY Dictionary Cache - Reduce DDL activities - Use the CACHE option for Sequences Program Global Area and the User Global Area - OPEN_CURSORS - SESSION_CACHED_CURSORS - CURSOR_SHARING Buffer Cache - configure multiple Buffer Pools 23
  • 24. OPTIMIZING I/O • Redologs on disks without other activities • Redo logs and Archived redo logs on separate disks • Heavily accessed files on separate disk • Distribute the data files based on disk controller allocation • Separate disks for data that is not related to the database • Striping objects across multiple disks • Distribute table and related indexes on different disks 24
  • 25. OPTIMIZING CONTENTION Detecting and preventing lock contention - V$LOCK, V$ENQUEUE_LOCK, V$ENQUEUE_LOCK, DBA_WAITERS, DBA_BLOCKERS Latches – Is there any Tuning? - V$SYSTEM_EVENT 25