SlideShare a Scribd company logo
1 of 58
<Insert Picture Here>
Performance Summit – OLTP Performance
Andrew Holdsworth, Tom Kyte, Graham Wood
Server Technologies, Oracle Corp
<Insert Picture Here>
Computer Science
It is mostly about simple math
0
2000
4000
6000
8000
10000
12000
14000
16000
4 8 12 16 20 24 28 32
1 Proc/Core
10 Proc/Core Avg
50 Proc/Core Avg
10 Proc/Core Max
50 Proc/Core Max
10 Proc/Core Min
50 Proc/Core Min
How much work can you do – “it depends”
Sessions & Cursors ( This slide is over 10 years old! But still true today )
Database Performance Core Principles
• To determine acceptable CPU utilization take a
probabilistic approach to the subject.
– If a CPU is 50% busy the chance of getting scheduled is 1 in 2
– If a CPU is 66% busy the chance of getting scheduled is 1 in 3
– If a CPU is 80% busy the chance of getting scheduled is 1 in 5
– If a CPU is 90% busy the chance of getting scheduled is 1 in10
• If the probabilities are used as indicator of the
predictability of user response time, then the variance
in user response time becomes noticeable at about
60-65%
• This has been observed in production and laboratory
conditions for many years.
Performance Buzz
Talk is Cheap! Performance is not!
• There is much jargon and many buzzwords used in
connection with computers and data processing.
• Do you know what they really mean?
Latency
Throughput
Response Time Efficiency
Real Time
Linear Scaling
Horizontal Scaling
Cache Efficiency
Transaction Rate
<Insert Picture Here>
Making Connections
Three Ways to create a physical connection
• Dedicated Server
– Slow connection
– Short code path
• Shared Server
– Fast connection
– Long code path
• Database Resident Connection Pooling (DRCP)
– Fast connection
– Short code path
– Limited Availability
client
ds
1
2
2
3
SGADedicated Server
Slow connection
Has process creation
Short code path however
s001
s002
s003
s00n
…
d001
client
Request
queue
Response
queue
1
2
3
4
45
6
7
SGAShared Server
Fast connection
No process creation
Long code path however
ds
client
1
2
2
3
SGADRCP
Fast connection
No process creation
Short code path
ds
ds
.
.
ds
client
SGADRCP
Fast connection
No process creation
Short code path
ds
ds
.
.
Connection Architecture
Connection Storms
• May be caused by application servers that allow the
size of the pool of database connections to increase
rapidly when the pool is exhausted
• A connection storm may take the number of
connections from hundreds to thousands in a matter
of seconds
• The process creation and logon activity may mask the
real problem of why the connection pool was
exhausted and make debugging a longer process
• A connection storm may render the database server
unstable, unusable
Connection Architecture
The Anatomy of a Connection Storm
Connection Architecture
The Anatomy of a Connection Storm
Connection Architecture
The Anatomy of a Connection Storm
Connection Architecture
The Anatomy of a Connection Storm
Connection Architecture
Non Intuitive Connection Storm
• Normally, your system ramps up to a steady state
slowly over time
• All is well
• Until a disaster strikes – and you failover
• Is your Disaster Recovery solution a failure just
waiting to happen itself
– Because you’ve “over connected” your existing data slowly
over time.
Sessions and Cursors
Are Your Clients Vulnerable to a Connection Storm?
• Do you do DR on a system with more than a few
dozen connections?
• Does your AWR or Statspack report show a logon/off
rate > 1 per second over a period of time?
• Have you set processes to a high value as a band-
aid?
• Have you even thought about it?
– How many connections do you really need?
– What could/would happen if that number is much larger than
the number of processing cores you have available?
<Insert Picture Here>
Concurrency or Not
What is concurrency
What defines concurrency?
• Is it many connections to a database?
• Is it transactions per second?
• Is it having many active sessions?
• Is it actively doing constructive work on all of your
CPUs at the same time?
“Oracle is highly concurrent and scalable.
So you don’t have to be”
Well…
report
update
Before
Image
accurate
Person Table
The “story” (or the myth if you will)
You are concurrent without having to do anything at all…
• Updates don’t lockout
reports and reports don’t
lockout updates
• Reports see only committed
data via Multi-Versioning
• Queries yield maximum
throughput with correct
results - no waiting and no
dirty reads!
• Row locks never escalate -
the most scalable solution
available
What are major concurrency inhibitors?
• Just one – shared resources that are not shared
nicely
– Many sessions updating the same row (enqueue locks)
– Many sessions updating the same shared memory bits (latch,
mutex contention)
– Many sessions updating the same block(s) (current mode
gets – buffer busy waits)
– Many sessions trying to read the same devices (IO)
– Many sessions trying to simply be active at the same time
(CPU)
– Many sessions trying to sort at the same time
– And so on
How do you solve concurrency issues?
• There is fortunately…
– A single answer
– That answers all concurrency issues
– Absolutely and completely.
– It is….
“It Depends…”
For example…
Hot right hand side index
• Populated by sequence
(monotonically increasing
value)
• Hundreds/Thousands of
attempted concurrent inserts
• Massive contention for the
right hand side block
• How do you solve it?
<Insert Picture Here>
SQL and Statistics
Why do we gather statistics?
How frequently do you gather statistics
• There is fortunately…
– A single answer
– That answers all statistics gathering frequency questions
– Absolutely and completely.
– It is….
It depends of course
Statistics Frequency
• Maybe once and never again (rare)
– Global temporary tables, just get a representative sample
• Maybe every day (unlikely)
– Newly added partitions on a daily basis
– Rapidly changing data characteristics
• Maybe on a much larger period (typical)
– Most data doesn’t change that often, that massively
– Most plans won’t change with the same statistics
• Bind peeking can affect that however
• Lack of binds can affect that as well – it is the boundary
conditions we need to be concerned about
Statistics Style
• Auto Job?
• Defaults?
– Do you really want histograms?
– Do you really want silent changes?
• Estimate or Compute?
• Maybe we just set them?
• What about incremental?...
Gathering Statistics
Incremental Statistics
• One of the biggest problems with large tables is
keeping the schema statistics up to date and accurate
• To address this problem, 11.1 introduced the concept
of incremental statistics for partitioned objects
• This means that statistics are gathered for recently
modified partitions
Gathering Statistics
The Concept of Synopses
• It is not possible to simply add partition statistics
together to create an up to date set of global statistics
• This is because the Number of Distinct Values (NDV)
for a partition may include values common to multiple
partitions.
• To resolve this problem, compressed representations
of the distinct values of each column are created in a
structure in the SYSAUX tablespace known as a
synopsis
Gathering Statistics
Synopsis Example
Object Column Values NDV
Partition #1 1,1,3,4,5 4
Partition #2 1,2,3,4,5 5
NDV by addition WRONG 9
NDV by Synopsis CORRECT 5
<Insert Picture Here>
SQL and Writing It
Application Design and SQL
• Relational System Design Basics
– Relational databases became so popular because they boost
application development productivity.
– Relational databases have been proven to scale with increasing data
volumes
– Relational databases provide the means to evolve and answer
multiple business questions
• This means designing a relational database
– Not a hierarchical database
– Not an object database
• This means going back to basics
– Data Modeling
– Normalization of Data
– Compromises between Logical and Physical models
SQL Statements
• It cannot be emphasized enough SQL statements
have more impact than any other performance
variable.
– Well written SQL statements that define the data to be
queried, updated etc is always the first problem. This is
clearly the responsibility of the developer or tool vendor.
– Optimizing the SQL efficiently is a mixture of the DBAs and
the Database’s responsibility
• DBA need to maintain good schema statistics to enable the
database make good cardinality estimates
• The Database needs choose efficient plans based upon good
schema statistics
SQL Design and Implementation
• Basic Checks for SQL statements and schemas
– Check for parse errors
– Validate correct join conditions specified
– Caution with implicit data type conversions
– Caution with wildcards and functions
– Caution on fuzzy joins
SQL Optimization
• This is probably where you should be spending the majority of
your time.
• The time should be spent determining/validating the appropriate
execution plan
• Correct index/access method
• Correct partition pruning strategy
• Correct join order and type
• Correct parallelization level
• Beware of binary and reactionary behavior e.g
– We got burnt on hash joins so we disable them
– We never use histograms as they ruin our plans
• Much of this process is matching appropriate database
technology to appropriate database challenges
– This process is not learnt from a book!
SQL Statements - Parsing
• Even if the SQL statement is performing well – you
might be doing extra non-necessary work
• That is called parsing
• There are three types of parsing (maybe four) in
Oracle:
– Hard parse (very very very bad)
– Soft parse (very very bad)
– Softer Soft parse (very bad)
– Absence of a parse – no parse (good)
Bind01-02-03.sql
SQL Statements – the importance of constraints
When the developed SQL isn’t very good…
ops$tkyte%ORA11GR2> CREATE TABLE T1
2 (
3 ORDER_ID NUMBER(18) NOT NULL,
4 ACCOUNT_NO NUMBER(10) NOT NULL,
5 ORDER_NUMBER VARCHAR2(20) NOT NULL,
6 data varchar2(1000)
7 );
Table created.
ops$tkyte%ORA11GR2> ALTER TABLE T1 ADD CONSTRAINT T1_PK1 PRIMARY KEY (ORDER_ID);
Table altered.
ops$tkyte%ORA11GR2> CREATE TABLE T2
2 (
3 SERVICE_ORDER_ID NUMBER(18) NOT NULL,
4 ORDER_ID NUMBER(18) NOT NULL,
5 ORDER_STATUS_ID NUMBER(6) NOT NULL,
6 data varchar2(1000)
7 );
Table created.
ops$tkyte%ORA11GR2> ALTER TABLE T2 ADD CONSTRAINT T2_PK1
2 PRIMARY KEY (SERVICE_ORDER_ID);
Table altered.
ops$tkyte%ORA11GR2> ALTER TABLE T2 ADD CONSTRAINT T2_OSO_FK1
2 FOREIGN KEY (ORDER_ID) REFERENCES T1 (ORDER_ID);
Table altered.
SQL Statements –
When the developed SQL isn’t very good…
ops$tkyte%ORA11GR2> CREATE TABLE T3
2 (
3 SERVICE_ORDER_ID NUMBER(18) NOT NULL,
4 RELATED_SERVICE_ORDER_ID NUMBER(18),
5 data varchar2(1000)
6 );
Table created.
ops$tkyte%ORA11GR2> ALTER TABLE T3 ADD CONSTRAINT T3_ORDER_PK1
2 PRIMARY KEY (SERVICE_ORDER_ID);
Table altered.
ops$tkyte%ORA11GR2> ALTER TABLE T3 ADD CONSTRAINT T3_OLS_S_FK1
2 FOREIGN KEY (SERVICE_ORDER_ID) REFERENCES T2 (SERVICE_ORDER_ID);
Table altered.
ops$tkyte%ORA11GR2> CREATE INDEX T3_OLS_RS_1
2 ON T3 (RELATED_SERVICE_ORDER_ID);
Index created.
SQL Statements –
When the developed SQL isn’t very good…
ops$tkyte%ORA10GR2> SELECT COUNT(*)
2 FROM T1, T2, T3
3 WHERE T2.order_id = T1.order_id
4 AND T2.service_order_id = T3.service_order_id (+)
5 AND T3.related_service_order_id = TO_NUMBER(:v0);
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 65 | 2 |
| 1 | SORT AGGREGATE | | 1 | 65 | |
| 2 | NESTED LOOPS | | 1 | 65 | 2 |
| 3 | NESTED LOOPS | | 1 | 52 | 2 |
| 4 | TABLE ACCESS BY INDEX ROWID| T3 | 1 | 26 | 1 |
|* 5 | INDEX RANGE SCAN | T3_OLS_RS_1 | 1 | | 1 |
| 6 | TABLE ACCESS BY INDEX ROWID| T2 | 1 | 26 | 1 |
|* 7 | INDEX UNIQUE SCAN | T2_PK1 | 1 | | |
|* 8 | INDEX UNIQUE SCAN | T1_PK1 | 1 | 13 | |
------------------------------------------------------------------------------
ops$tkyte%ORA11GR2> SELECT COUNT(*)
2 FROM T1, T2, T3
3 WHERE T2.order_id = T1.order_id
4 AND T2.service_order_id = T3.service_order_id (+)
5 AND T3.related_service_order_id = TO_NUMBER(:v0);
---------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 26 | 1 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 26 | | |
|* 2 | INDEX RANGE SCAN| T3_OLS_RS_1 | 1 | 26 | 1 (0)| 00:00:01 |
---------------------------------------------------------------------------------
SQL Statements –
When the developed SQL isn’t very good…
ops$tkyte%ORA11GR2> set autotrace traceonly explain
ops$tkyte%ORA11GR2> SELECT COUNT(*)
2 FROM T1, T2, T3
3 WHERE T2.order_id = T1.order_id
4 AND T2.service_order_id = T3.service_order_id
(+)
5 AND T3.related_service_order_id =
TO_NUMBER(:v0);
• First, it knows the outer join is not necessary
– Where t2.col = t3.col(+) and t3.anything = ‘something’
– Implies the (+) is not necessary
• If the outer join ‘happened’, then t3.anything would be
NULL! And t3.anything = to_number(:v0) would never
be satisfied
ops$tkyte%ORA11GR2> set autotrace traceonly explain
ops$tkyte%ORA11GR2> SELECT COUNT(*)
2 FROM T1, T2, T3
3 WHERE T2.order_id = T1.order_id
4 AND T2.service_order_id = T3.service_order_id
5 AND T3.related_service_order_id = TO_NUMBER(:v0);
SQL Statements –
When the developed SQL isn’t very good…
ops$tkyte%ORA11GR2> set autotrace traceonly explain
ops$tkyte%ORA11GR2> SELECT COUNT(*)
2 FROM T1, T2, T3
3 WHERE T2.order_id = T1.order_id
4 AND T2.service_order_id = T3.service_order_id
(+)
5 AND T3.related_service_order_id =
TO_NUMBER(:v0);
• Second, it knows that T1 is not relevant to the query
– Nothing is selected from T1 in the output
– T1(order_id) is the primary key, joined to T2(order_id) – so T2
is “key preserved”
– T2(order_id) is NOT NULL and is a foreign key to T1
– Therefore, when you join T1 to T2 – every row in T2 appears
at least once and at most once in the output
ops$tkyte%ORA11GR2> set autotrace traceonly explain
ops$tkyte%ORA11GR2> SELECT COUNT(*)
2 FROM T2, T3
3 WHERE T2.service_order_id = T3.service_order_id
4 AND T3.related_service_order_id = TO_NUMBER(:v0);
SQL Statements –
When the developed SQL isn’t very good…
ops$tkyte%ORA11GR2> set autotrace traceonly explain
ops$tkyte%ORA11GR2> SELECT COUNT(*)
2 FROM T1, T2, T3
3 WHERE T2.order_id = T1.order_id
4 AND T2.service_order_id = T3.service_order_id
(+)
5 AND T3.related_service_order_id =
TO_NUMBER(:v0);
• Lastly, it knows that T2 is not relevant to the query
– Nothing is selected from T2 in the output
– T2(service_order_id) is the primary key, joined to
T3(service_order_id) – so T3 is “key preserved”
– T3(service_order_id) is NOT NULL and is a foreign key to T2
– Therefore, when you join T2 to T3 – every row in T3 appears
at least once and at most once in the output
ops$tkyte%ORA11GR2> set autotrace traceonly explain
ops$tkyte%ORA11GR2> SELECT COUNT(*)
2 FROM T3
3 WHERE T3.related_service_order_id = TO_NUMBER(:v0);
SQL Statements –
When the developed SQL isn’t very good…
ops$tkyte%ORA11GR2> SELECT COUNT(*)
2 FROM T1, T2, T3
3 WHERE T2.order_id = T1.order_id
4 AND T2.service_order_id = T3.service_order_id (+)
5 AND T3.related_service_order_id = TO_NUMBER(:v0);
ops$tkyte%ORA11GR2> SELECT COUNT(*)
2 FROM T3
3 WHERE T3.related_service_order_id = TO_NUMBER(:v0);
Is the same as….
But only because of the constraints in place…
SQL Statements – the importance of constraints
When the developed SQL isn’t very good…
SQL Statements – wrapup
• Average performance engineers very quickly learn the
following skills:
– Identification of resource intensive or poorly performing SQL
– Identification of potentially better execution plans
• Really good performance engineers are able to:
– Use cardinality estimates to identify why suboptimal execution
plans were chosen
– Take corrective action by either fixing the statistics, hand
tuning the SQL or by logging bugs
• Bad performance engineers
– Start hacking init.ora parameters on a per SQL statement
basis in random manner
SQL Statements – wrapup
• It is not just about raw SQL performance, how the
application interacts with the database counts too
– Parsing
– Array processing
• Metadata Matters
– To the optimizer, just like statistics
<Insert Picture Here>
Application Instrumentation
Let us know who you are
• Dbms_session.set_identifier
– Audited
– Used by dbms_monitor tracking
• Dbms_application_info
– Set client info
– Set action
– Set module
– Instantly visible – gives context
• Dbms_application_info
– Set session longops
Automatic Workload Repository (AWR)
• Every N-Units of time, data is flushed from memory to
disk (a snapshot)
• You can generate reports that cover any range of time
(n-units of time at a time)
• We simply “subtract”
T1 T2 T3 T4
You can report on:
T2-T1
T3-T2
T3-T1
T4-T3
T4-T2
T4-T1
Shutdown/startup
You can report on:
T3-T2
T4-T3
T4-T2
select * from
dba_hist_snapshot;
Active Session History (ASH)
• V$ACTIVE_SESSION_HISTORY – about every second of
activity
• DBA_HIST_ACTIVE_SESS_HISTORY – every 10 seconds of
activity
– On demand flush
– When ever in memory buffer (V$) is 2/3rds full
– Retained using AWR retention policies
Point in time:
V$SESSION
V$SESSION_WAIT
SGA Circular
Buffer – sized
By CPU_COUNT
Short term memory:
V$ACTIVE_SESSION_HISTORY
Long term memory:
DBA_HIST_ACTIVE_SESS_HISTORY
Every hour or
2/3rds full in SGA
Instrumentation
• Think back to version 6… How would you tune a
system (or systems) of todays scope without it?
• The database does much of it for you
• You still have to participate a bit
– Dbms_application_info
– Dbms_session
<Insert Picture Here>
Applications and Conversations
Real World Performance - OLTP

More Related Content

Similar to Real World Performance - OLTP

Performance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL DatabasePerformance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL DatabaseTung Nguyen Thanh
 
Building Big Data Streaming Architectures
Building Big Data Streaming ArchitecturesBuilding Big Data Streaming Architectures
Building Big Data Streaming ArchitecturesDavid Martínez Rego
 
The Rise of NoSQL and Polyglot Persistence
The Rise of NoSQL and Polyglot PersistenceThe Rise of NoSQL and Polyglot Persistence
The Rise of NoSQL and Polyglot PersistenceAbdelmonaim Remani
 
NoSQLDatabases
NoSQLDatabasesNoSQLDatabases
NoSQLDatabasesAdi Challa
 
Observability – the good, the bad, and the ugly
Observability – the good, the bad, and the uglyObservability – the good, the bad, and the ugly
Observability – the good, the bad, and the uglyTimetrix
 
Patterns of enterprise application architecture
Patterns of enterprise application architecturePatterns of enterprise application architecture
Patterns of enterprise application architectureChinh Ngo Nguyen
 
Big Data Day LA 2015 - Lessons Learned Designing Data Ingest Systems
Big Data Day LA 2015 - Lessons Learned Designing Data Ingest SystemsBig Data Day LA 2015 - Lessons Learned Designing Data Ingest Systems
Big Data Day LA 2015 - Lessons Learned Designing Data Ingest Systemsaaamase
 
Database Systems - Lecture Week 1
Database Systems - Lecture Week 1Database Systems - Lecture Week 1
Database Systems - Lecture Week 1Dios Kurniawan
 
Big iron 2 (published)
Big iron 2 (published)Big iron 2 (published)
Big iron 2 (published)Ben Stopford
 
Building data intensive applications
Building data intensive applicationsBuilding data intensive applications
Building data intensive applicationsAmit Kejriwal
 
Scaling Systems: Architectures that grow
Scaling Systems: Architectures that growScaling Systems: Architectures that grow
Scaling Systems: Architectures that growGibraltar Software
 
DataIntensiveComputing.pdf
DataIntensiveComputing.pdfDataIntensiveComputing.pdf
DataIntensiveComputing.pdfBrahmam8
 
One Size Doesn't Fit All: The New Database Revolution
One Size Doesn't Fit All: The New Database RevolutionOne Size Doesn't Fit All: The New Database Revolution
One Size Doesn't Fit All: The New Database Revolutionmark madsen
 
Sql azure cluster dashboard public.ppt
Sql azure cluster dashboard public.pptSql azure cluster dashboard public.ppt
Sql azure cluster dashboard public.pptQingsong Yao
 
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
 
SPL_ALL_EN.pptx
SPL_ALL_EN.pptxSPL_ALL_EN.pptx
SPL_ALL_EN.pptx政宏 张
 

Similar to Real World Performance - OLTP (20)

Performance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL DatabasePerformance Tuning And Optimization Microsoft SQL Database
Performance Tuning And Optimization Microsoft SQL Database
 
Building Big Data Streaming Architectures
Building Big Data Streaming ArchitecturesBuilding Big Data Streaming Architectures
Building Big Data Streaming Architectures
 
NoSQL and Couchbase
NoSQL and CouchbaseNoSQL and Couchbase
NoSQL and Couchbase
 
The Rise of NoSQL and Polyglot Persistence
The Rise of NoSQL and Polyglot PersistenceThe Rise of NoSQL and Polyglot Persistence
The Rise of NoSQL and Polyglot Persistence
 
Training - What is Performance ?
Training  - What is Performance ?Training  - What is Performance ?
Training - What is Performance ?
 
NoSQLDatabases
NoSQLDatabasesNoSQLDatabases
NoSQLDatabases
 
Observability – the good, the bad, and the ugly
Observability – the good, the bad, and the uglyObservability – the good, the bad, and the ugly
Observability – the good, the bad, and the ugly
 
Patterns of enterprise application architecture
Patterns of enterprise application architecturePatterns of enterprise application architecture
Patterns of enterprise application architecture
 
Big Data Day LA 2015 - Lessons Learned Designing Data Ingest Systems
Big Data Day LA 2015 - Lessons Learned Designing Data Ingest SystemsBig Data Day LA 2015 - Lessons Learned Designing Data Ingest Systems
Big Data Day LA 2015 - Lessons Learned Designing Data Ingest Systems
 
try
trytry
try
 
Database Systems - Lecture Week 1
Database Systems - Lecture Week 1Database Systems - Lecture Week 1
Database Systems - Lecture Week 1
 
Big iron 2 (published)
Big iron 2 (published)Big iron 2 (published)
Big iron 2 (published)
 
Building data intensive applications
Building data intensive applicationsBuilding data intensive applications
Building data intensive applications
 
Scaling Systems: Architectures that grow
Scaling Systems: Architectures that growScaling Systems: Architectures that grow
Scaling Systems: Architectures that grow
 
DataIntensiveComputing.pdf
DataIntensiveComputing.pdfDataIntensiveComputing.pdf
DataIntensiveComputing.pdf
 
One Size Doesn't Fit All: The New Database Revolution
One Size Doesn't Fit All: The New Database RevolutionOne Size Doesn't Fit All: The New Database Revolution
One Size Doesn't Fit All: The New Database Revolution
 
Sql azure cluster dashboard public.ppt
Sql azure cluster dashboard public.pptSql azure cluster dashboard public.ppt
Sql azure cluster dashboard public.ppt
 
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...
 
Redshift deep dive
Redshift deep diveRedshift deep dive
Redshift deep dive
 
SPL_ALL_EN.pptx
SPL_ALL_EN.pptxSPL_ALL_EN.pptx
SPL_ALL_EN.pptx
 

More from Connor McDonald

Sangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolestSangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolestConnor McDonald
 
Sangam 19 - Analytic SQL
Sangam 19 - Analytic SQLSangam 19 - Analytic SQL
Sangam 19 - Analytic SQLConnor McDonald
 
UKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsUKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsConnor McDonald
 
Sangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on AutonomousSangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on AutonomousConnor McDonald
 
Sangam 2019 - The Latest Features
Sangam 2019 - The Latest FeaturesSangam 2019 - The Latest Features
Sangam 2019 - The Latest FeaturesConnor McDonald
 
UKOUG 2019 - SQL features
UKOUG 2019 - SQL featuresUKOUG 2019 - SQL features
UKOUG 2019 - SQL featuresConnor McDonald
 
APEX tour 2019 - successful development with autonomous
APEX tour 2019 - successful development with autonomousAPEX tour 2019 - successful development with autonomous
APEX tour 2019 - successful development with autonomousConnor McDonald
 
APAC Groundbreakers 2019 - Perth/Melbourne
APAC Groundbreakers 2019 - Perth/Melbourne APAC Groundbreakers 2019 - Perth/Melbourne
APAC Groundbreakers 2019 - Perth/Melbourne Connor McDonald
 
OOW19 - Flashback, not just for DBAs
OOW19 - Flashback, not just for DBAsOOW19 - Flashback, not just for DBAs
OOW19 - Flashback, not just for DBAsConnor McDonald
 
OOW19 - Read consistency
OOW19 - Read consistencyOOW19 - Read consistency
OOW19 - Read consistencyConnor McDonald
 
OOW19 - Slower and less secure applications
OOW19 - Slower and less secure applicationsOOW19 - Slower and less secure applications
OOW19 - Slower and less secure applicationsConnor McDonald
 
OOW19 - Killing database sessions
OOW19 - Killing database sessionsOOW19 - Killing database sessions
OOW19 - Killing database sessionsConnor McDonald
 
OOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL featuresOOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL featuresConnor McDonald
 
Latin America Tour 2019 - 18c and 19c featues
Latin America Tour 2019   - 18c and 19c featuesLatin America Tour 2019   - 18c and 19c featues
Latin America Tour 2019 - 18c and 19c featuesConnor McDonald
 
Latin America tour 2019 - Flashback
Latin America tour 2019 -  FlashbackLatin America tour 2019 -  Flashback
Latin America tour 2019 - FlashbackConnor McDonald
 
Latin America Tour 2019 - 10 great sql features
Latin America Tour 2019  - 10 great sql featuresLatin America Tour 2019  - 10 great sql features
Latin America Tour 2019 - 10 great sql featuresConnor McDonald
 
Latin America Tour 2019 - pattern matching
Latin America Tour 2019 - pattern matchingLatin America Tour 2019 - pattern matching
Latin America Tour 2019 - pattern matchingConnor McDonald
 
Latin America Tour 2019 - slow data and sql processing
Latin America Tour 2019  - slow data and sql processingLatin America Tour 2019  - slow data and sql processing
Latin America Tour 2019 - slow data and sql processingConnor McDonald
 

More from Connor McDonald (20)

Flashback ITOUG
Flashback ITOUGFlashback ITOUG
Flashback ITOUG
 
Sangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolestSangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolest
 
Sangam 19 - Analytic SQL
Sangam 19 - Analytic SQLSangam 19 - Analytic SQL
Sangam 19 - Analytic SQL
 
UKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsUKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tips
 
Sangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on AutonomousSangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on Autonomous
 
Sangam 2019 - The Latest Features
Sangam 2019 - The Latest FeaturesSangam 2019 - The Latest Features
Sangam 2019 - The Latest Features
 
UKOUG 2019 - SQL features
UKOUG 2019 - SQL featuresUKOUG 2019 - SQL features
UKOUG 2019 - SQL features
 
APEX tour 2019 - successful development with autonomous
APEX tour 2019 - successful development with autonomousAPEX tour 2019 - successful development with autonomous
APEX tour 2019 - successful development with autonomous
 
APAC Groundbreakers 2019 - Perth/Melbourne
APAC Groundbreakers 2019 - Perth/Melbourne APAC Groundbreakers 2019 - Perth/Melbourne
APAC Groundbreakers 2019 - Perth/Melbourne
 
OOW19 - Flashback, not just for DBAs
OOW19 - Flashback, not just for DBAsOOW19 - Flashback, not just for DBAs
OOW19 - Flashback, not just for DBAs
 
OOW19 - Read consistency
OOW19 - Read consistencyOOW19 - Read consistency
OOW19 - Read consistency
 
OOW19 - Slower and less secure applications
OOW19 - Slower and less secure applicationsOOW19 - Slower and less secure applications
OOW19 - Slower and less secure applications
 
OOW19 - Killing database sessions
OOW19 - Killing database sessionsOOW19 - Killing database sessions
OOW19 - Killing database sessions
 
OOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL featuresOOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL features
 
Latin America Tour 2019 - 18c and 19c featues
Latin America Tour 2019   - 18c and 19c featuesLatin America Tour 2019   - 18c and 19c featues
Latin America Tour 2019 - 18c and 19c featues
 
Latin America tour 2019 - Flashback
Latin America tour 2019 -  FlashbackLatin America tour 2019 -  Flashback
Latin America tour 2019 - Flashback
 
Latin America Tour 2019 - 10 great sql features
Latin America Tour 2019  - 10 great sql featuresLatin America Tour 2019  - 10 great sql features
Latin America Tour 2019 - 10 great sql features
 
Latin America Tour 2019 - pattern matching
Latin America Tour 2019 - pattern matchingLatin America Tour 2019 - pattern matching
Latin America Tour 2019 - pattern matching
 
Latin America Tour 2019 - slow data and sql processing
Latin America Tour 2019  - slow data and sql processingLatin America Tour 2019  - slow data and sql processing
Latin America Tour 2019 - slow data and sql processing
 
ANSI vs Oracle language
ANSI vs Oracle languageANSI vs Oracle language
ANSI vs Oracle language
 

Recently uploaded

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 

Recently uploaded (20)

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 

Real World Performance - OLTP

  • 1. <Insert Picture Here> Performance Summit – OLTP Performance Andrew Holdsworth, Tom Kyte, Graham Wood Server Technologies, Oracle Corp
  • 3. It is mostly about simple math 0 2000 4000 6000 8000 10000 12000 14000 16000 4 8 12 16 20 24 28 32 1 Proc/Core 10 Proc/Core Avg 50 Proc/Core Avg 10 Proc/Core Max 50 Proc/Core Max 10 Proc/Core Min 50 Proc/Core Min
  • 4. How much work can you do – “it depends” Sessions & Cursors ( This slide is over 10 years old! But still true today )
  • 5. Database Performance Core Principles • To determine acceptable CPU utilization take a probabilistic approach to the subject. – If a CPU is 50% busy the chance of getting scheduled is 1 in 2 – If a CPU is 66% busy the chance of getting scheduled is 1 in 3 – If a CPU is 80% busy the chance of getting scheduled is 1 in 5 – If a CPU is 90% busy the chance of getting scheduled is 1 in10 • If the probabilities are used as indicator of the predictability of user response time, then the variance in user response time becomes noticeable at about 60-65% • This has been observed in production and laboratory conditions for many years.
  • 6. Performance Buzz Talk is Cheap! Performance is not! • There is much jargon and many buzzwords used in connection with computers and data processing. • Do you know what they really mean? Latency Throughput Response Time Efficiency Real Time Linear Scaling Horizontal Scaling Cache Efficiency Transaction Rate
  • 8. Three Ways to create a physical connection • Dedicated Server – Slow connection – Short code path • Shared Server – Fast connection – Long code path • Database Resident Connection Pooling (DRCP) – Fast connection – Short code path – Limited Availability
  • 9. client ds 1 2 2 3 SGADedicated Server Slow connection Has process creation Short code path however
  • 11. ds client 1 2 2 3 SGADRCP Fast connection No process creation Short code path ds ds . .
  • 12. ds client SGADRCP Fast connection No process creation Short code path ds ds . .
  • 13. Connection Architecture Connection Storms • May be caused by application servers that allow the size of the pool of database connections to increase rapidly when the pool is exhausted • A connection storm may take the number of connections from hundreds to thousands in a matter of seconds • The process creation and logon activity may mask the real problem of why the connection pool was exhausted and make debugging a longer process • A connection storm may render the database server unstable, unusable
  • 14. Connection Architecture The Anatomy of a Connection Storm
  • 15. Connection Architecture The Anatomy of a Connection Storm
  • 16. Connection Architecture The Anatomy of a Connection Storm
  • 17. Connection Architecture The Anatomy of a Connection Storm
  • 18. Connection Architecture Non Intuitive Connection Storm • Normally, your system ramps up to a steady state slowly over time • All is well • Until a disaster strikes – and you failover • Is your Disaster Recovery solution a failure just waiting to happen itself – Because you’ve “over connected” your existing data slowly over time.
  • 19. Sessions and Cursors Are Your Clients Vulnerable to a Connection Storm? • Do you do DR on a system with more than a few dozen connections? • Does your AWR or Statspack report show a logon/off rate > 1 per second over a period of time? • Have you set processes to a high value as a band- aid? • Have you even thought about it? – How many connections do you really need? – What could/would happen if that number is much larger than the number of processing cores you have available?
  • 21. What is concurrency What defines concurrency? • Is it many connections to a database? • Is it transactions per second? • Is it having many active sessions? • Is it actively doing constructive work on all of your CPUs at the same time?
  • 22. “Oracle is highly concurrent and scalable. So you don’t have to be” Well…
  • 23. report update Before Image accurate Person Table The “story” (or the myth if you will) You are concurrent without having to do anything at all… • Updates don’t lockout reports and reports don’t lockout updates • Reports see only committed data via Multi-Versioning • Queries yield maximum throughput with correct results - no waiting and no dirty reads! • Row locks never escalate - the most scalable solution available
  • 24. What are major concurrency inhibitors? • Just one – shared resources that are not shared nicely – Many sessions updating the same row (enqueue locks) – Many sessions updating the same shared memory bits (latch, mutex contention) – Many sessions updating the same block(s) (current mode gets – buffer busy waits) – Many sessions trying to read the same devices (IO) – Many sessions trying to simply be active at the same time (CPU) – Many sessions trying to sort at the same time – And so on
  • 25. How do you solve concurrency issues? • There is fortunately… – A single answer – That answers all concurrency issues – Absolutely and completely. – It is….
  • 27. Hot right hand side index • Populated by sequence (monotonically increasing value) • Hundreds/Thousands of attempted concurrent inserts • Massive contention for the right hand side block • How do you solve it?
  • 28. <Insert Picture Here> SQL and Statistics
  • 29. Why do we gather statistics?
  • 30. How frequently do you gather statistics • There is fortunately… – A single answer – That answers all statistics gathering frequency questions – Absolutely and completely. – It is…. It depends of course
  • 31. Statistics Frequency • Maybe once and never again (rare) – Global temporary tables, just get a representative sample • Maybe every day (unlikely) – Newly added partitions on a daily basis – Rapidly changing data characteristics • Maybe on a much larger period (typical) – Most data doesn’t change that often, that massively – Most plans won’t change with the same statistics • Bind peeking can affect that however • Lack of binds can affect that as well – it is the boundary conditions we need to be concerned about
  • 32. Statistics Style • Auto Job? • Defaults? – Do you really want histograms? – Do you really want silent changes? • Estimate or Compute? • Maybe we just set them? • What about incremental?...
  • 33. Gathering Statistics Incremental Statistics • One of the biggest problems with large tables is keeping the schema statistics up to date and accurate • To address this problem, 11.1 introduced the concept of incremental statistics for partitioned objects • This means that statistics are gathered for recently modified partitions
  • 34. Gathering Statistics The Concept of Synopses • It is not possible to simply add partition statistics together to create an up to date set of global statistics • This is because the Number of Distinct Values (NDV) for a partition may include values common to multiple partitions. • To resolve this problem, compressed representations of the distinct values of each column are created in a structure in the SYSAUX tablespace known as a synopsis
  • 35. Gathering Statistics Synopsis Example Object Column Values NDV Partition #1 1,1,3,4,5 4 Partition #2 1,2,3,4,5 5 NDV by addition WRONG 9 NDV by Synopsis CORRECT 5
  • 36. <Insert Picture Here> SQL and Writing It
  • 37. Application Design and SQL • Relational System Design Basics – Relational databases became so popular because they boost application development productivity. – Relational databases have been proven to scale with increasing data volumes – Relational databases provide the means to evolve and answer multiple business questions • This means designing a relational database – Not a hierarchical database – Not an object database • This means going back to basics – Data Modeling – Normalization of Data – Compromises between Logical and Physical models
  • 38. SQL Statements • It cannot be emphasized enough SQL statements have more impact than any other performance variable. – Well written SQL statements that define the data to be queried, updated etc is always the first problem. This is clearly the responsibility of the developer or tool vendor. – Optimizing the SQL efficiently is a mixture of the DBAs and the Database’s responsibility • DBA need to maintain good schema statistics to enable the database make good cardinality estimates • The Database needs choose efficient plans based upon good schema statistics
  • 39. SQL Design and Implementation • Basic Checks for SQL statements and schemas – Check for parse errors – Validate correct join conditions specified – Caution with implicit data type conversions – Caution with wildcards and functions – Caution on fuzzy joins
  • 40. SQL Optimization • This is probably where you should be spending the majority of your time. • The time should be spent determining/validating the appropriate execution plan • Correct index/access method • Correct partition pruning strategy • Correct join order and type • Correct parallelization level • Beware of binary and reactionary behavior e.g – We got burnt on hash joins so we disable them – We never use histograms as they ruin our plans • Much of this process is matching appropriate database technology to appropriate database challenges – This process is not learnt from a book!
  • 41. SQL Statements - Parsing • Even if the SQL statement is performing well – you might be doing extra non-necessary work • That is called parsing • There are three types of parsing (maybe four) in Oracle: – Hard parse (very very very bad) – Soft parse (very very bad) – Softer Soft parse (very bad) – Absence of a parse – no parse (good) Bind01-02-03.sql
  • 42. SQL Statements – the importance of constraints When the developed SQL isn’t very good… ops$tkyte%ORA11GR2> CREATE TABLE T1 2 ( 3 ORDER_ID NUMBER(18) NOT NULL, 4 ACCOUNT_NO NUMBER(10) NOT NULL, 5 ORDER_NUMBER VARCHAR2(20) NOT NULL, 6 data varchar2(1000) 7 ); Table created. ops$tkyte%ORA11GR2> ALTER TABLE T1 ADD CONSTRAINT T1_PK1 PRIMARY KEY (ORDER_ID); Table altered.
  • 43. ops$tkyte%ORA11GR2> CREATE TABLE T2 2 ( 3 SERVICE_ORDER_ID NUMBER(18) NOT NULL, 4 ORDER_ID NUMBER(18) NOT NULL, 5 ORDER_STATUS_ID NUMBER(6) NOT NULL, 6 data varchar2(1000) 7 ); Table created. ops$tkyte%ORA11GR2> ALTER TABLE T2 ADD CONSTRAINT T2_PK1 2 PRIMARY KEY (SERVICE_ORDER_ID); Table altered. ops$tkyte%ORA11GR2> ALTER TABLE T2 ADD CONSTRAINT T2_OSO_FK1 2 FOREIGN KEY (ORDER_ID) REFERENCES T1 (ORDER_ID); Table altered. SQL Statements – When the developed SQL isn’t very good…
  • 44. ops$tkyte%ORA11GR2> CREATE TABLE T3 2 ( 3 SERVICE_ORDER_ID NUMBER(18) NOT NULL, 4 RELATED_SERVICE_ORDER_ID NUMBER(18), 5 data varchar2(1000) 6 ); Table created. ops$tkyte%ORA11GR2> ALTER TABLE T3 ADD CONSTRAINT T3_ORDER_PK1 2 PRIMARY KEY (SERVICE_ORDER_ID); Table altered. ops$tkyte%ORA11GR2> ALTER TABLE T3 ADD CONSTRAINT T3_OLS_S_FK1 2 FOREIGN KEY (SERVICE_ORDER_ID) REFERENCES T2 (SERVICE_ORDER_ID); Table altered. ops$tkyte%ORA11GR2> CREATE INDEX T3_OLS_RS_1 2 ON T3 (RELATED_SERVICE_ORDER_ID); Index created. SQL Statements – When the developed SQL isn’t very good…
  • 45. ops$tkyte%ORA10GR2> SELECT COUNT(*) 2 FROM T1, T2, T3 3 WHERE T2.order_id = T1.order_id 4 AND T2.service_order_id = T3.service_order_id (+) 5 AND T3.related_service_order_id = TO_NUMBER(:v0); ------------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost | ------------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | 1 | 65 | 2 | | 1 | SORT AGGREGATE | | 1 | 65 | | | 2 | NESTED LOOPS | | 1 | 65 | 2 | | 3 | NESTED LOOPS | | 1 | 52 | 2 | | 4 | TABLE ACCESS BY INDEX ROWID| T3 | 1 | 26 | 1 | |* 5 | INDEX RANGE SCAN | T3_OLS_RS_1 | 1 | | 1 | | 6 | TABLE ACCESS BY INDEX ROWID| T2 | 1 | 26 | 1 | |* 7 | INDEX UNIQUE SCAN | T2_PK1 | 1 | | | |* 8 | INDEX UNIQUE SCAN | T1_PK1 | 1 | 13 | | ------------------------------------------------------------------------------ ops$tkyte%ORA11GR2> SELECT COUNT(*) 2 FROM T1, T2, T3 3 WHERE T2.order_id = T1.order_id 4 AND T2.service_order_id = T3.service_order_id (+) 5 AND T3.related_service_order_id = TO_NUMBER(:v0); --------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | --------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 26 | 1 (0)| 00:00:01 | | 1 | SORT AGGREGATE | | 1 | 26 | | | |* 2 | INDEX RANGE SCAN| T3_OLS_RS_1 | 1 | 26 | 1 (0)| 00:00:01 | --------------------------------------------------------------------------------- SQL Statements – When the developed SQL isn’t very good…
  • 46. ops$tkyte%ORA11GR2> set autotrace traceonly explain ops$tkyte%ORA11GR2> SELECT COUNT(*) 2 FROM T1, T2, T3 3 WHERE T2.order_id = T1.order_id 4 AND T2.service_order_id = T3.service_order_id (+) 5 AND T3.related_service_order_id = TO_NUMBER(:v0); • First, it knows the outer join is not necessary – Where t2.col = t3.col(+) and t3.anything = ‘something’ – Implies the (+) is not necessary • If the outer join ‘happened’, then t3.anything would be NULL! And t3.anything = to_number(:v0) would never be satisfied ops$tkyte%ORA11GR2> set autotrace traceonly explain ops$tkyte%ORA11GR2> SELECT COUNT(*) 2 FROM T1, T2, T3 3 WHERE T2.order_id = T1.order_id 4 AND T2.service_order_id = T3.service_order_id 5 AND T3.related_service_order_id = TO_NUMBER(:v0); SQL Statements – When the developed SQL isn’t very good…
  • 47. ops$tkyte%ORA11GR2> set autotrace traceonly explain ops$tkyte%ORA11GR2> SELECT COUNT(*) 2 FROM T1, T2, T3 3 WHERE T2.order_id = T1.order_id 4 AND T2.service_order_id = T3.service_order_id (+) 5 AND T3.related_service_order_id = TO_NUMBER(:v0); • Second, it knows that T1 is not relevant to the query – Nothing is selected from T1 in the output – T1(order_id) is the primary key, joined to T2(order_id) – so T2 is “key preserved” – T2(order_id) is NOT NULL and is a foreign key to T1 – Therefore, when you join T1 to T2 – every row in T2 appears at least once and at most once in the output ops$tkyte%ORA11GR2> set autotrace traceonly explain ops$tkyte%ORA11GR2> SELECT COUNT(*) 2 FROM T2, T3 3 WHERE T2.service_order_id = T3.service_order_id 4 AND T3.related_service_order_id = TO_NUMBER(:v0); SQL Statements – When the developed SQL isn’t very good…
  • 48. ops$tkyte%ORA11GR2> set autotrace traceonly explain ops$tkyte%ORA11GR2> SELECT COUNT(*) 2 FROM T1, T2, T3 3 WHERE T2.order_id = T1.order_id 4 AND T2.service_order_id = T3.service_order_id (+) 5 AND T3.related_service_order_id = TO_NUMBER(:v0); • Lastly, it knows that T2 is not relevant to the query – Nothing is selected from T2 in the output – T2(service_order_id) is the primary key, joined to T3(service_order_id) – so T3 is “key preserved” – T3(service_order_id) is NOT NULL and is a foreign key to T2 – Therefore, when you join T2 to T3 – every row in T3 appears at least once and at most once in the output ops$tkyte%ORA11GR2> set autotrace traceonly explain ops$tkyte%ORA11GR2> SELECT COUNT(*) 2 FROM T3 3 WHERE T3.related_service_order_id = TO_NUMBER(:v0); SQL Statements – When the developed SQL isn’t very good…
  • 49. ops$tkyte%ORA11GR2> SELECT COUNT(*) 2 FROM T1, T2, T3 3 WHERE T2.order_id = T1.order_id 4 AND T2.service_order_id = T3.service_order_id (+) 5 AND T3.related_service_order_id = TO_NUMBER(:v0); ops$tkyte%ORA11GR2> SELECT COUNT(*) 2 FROM T3 3 WHERE T3.related_service_order_id = TO_NUMBER(:v0); Is the same as…. But only because of the constraints in place… SQL Statements – the importance of constraints When the developed SQL isn’t very good…
  • 50. SQL Statements – wrapup • Average performance engineers very quickly learn the following skills: – Identification of resource intensive or poorly performing SQL – Identification of potentially better execution plans • Really good performance engineers are able to: – Use cardinality estimates to identify why suboptimal execution plans were chosen – Take corrective action by either fixing the statistics, hand tuning the SQL or by logging bugs • Bad performance engineers – Start hacking init.ora parameters on a per SQL statement basis in random manner
  • 51. SQL Statements – wrapup • It is not just about raw SQL performance, how the application interacts with the database counts too – Parsing – Array processing • Metadata Matters – To the optimizer, just like statistics
  • 53. Let us know who you are • Dbms_session.set_identifier – Audited – Used by dbms_monitor tracking • Dbms_application_info – Set client info – Set action – Set module – Instantly visible – gives context • Dbms_application_info – Set session longops
  • 54. Automatic Workload Repository (AWR) • Every N-Units of time, data is flushed from memory to disk (a snapshot) • You can generate reports that cover any range of time (n-units of time at a time) • We simply “subtract” T1 T2 T3 T4 You can report on: T2-T1 T3-T2 T3-T1 T4-T3 T4-T2 T4-T1 Shutdown/startup You can report on: T3-T2 T4-T3 T4-T2 select * from dba_hist_snapshot;
  • 55. Active Session History (ASH) • V$ACTIVE_SESSION_HISTORY – about every second of activity • DBA_HIST_ACTIVE_SESS_HISTORY – every 10 seconds of activity – On demand flush – When ever in memory buffer (V$) is 2/3rds full – Retained using AWR retention policies Point in time: V$SESSION V$SESSION_WAIT SGA Circular Buffer – sized By CPU_COUNT Short term memory: V$ACTIVE_SESSION_HISTORY Long term memory: DBA_HIST_ACTIVE_SESS_HISTORY Every hour or 2/3rds full in SGA
  • 56. Instrumentation • Think back to version 6… How would you tune a system (or systems) of todays scope without it? • The database does much of it for you • You still have to participate a bit – Dbms_application_info – Dbms_session