SlideShare una empresa de Scribd logo
1 de 152
SQL TUNING 101
Alex Zaballa
Copyright © 2016 Accenture All rights reserved. | 2
Alex Zaballa
http://alexzaballa.blogspot.com/
@alexzaballa
https://www.linkedin.com/in/alexzaballa
275 and counting…
Copyright © 2016 Accenture All rights reserved. | 3
Worked for 3 years in Brazil as a Clipper/Delphi Developer (15 years old)
1997-1999
Worked for 7 years in Brazil as an Oracle Developer
2000 - 2007
Worked for 8 years in Angola as an Oracle DBA
for the Ministry of Finance.
2007 - 2015
Copyright © 2016 Accenture All rights reserved. | 4
Copyright © 2016 Accenture All rights reserved. | 5
3 Membership Tiers
• Oracle ACE Director
• Oracle ACE
• Oracle ACE Associate
bit.ly/OracleACEProgram
500+ Technical Experts
Helping Peers Globally
Connect:
Nominate yourself or someone you know: acenomination.oracle.com
@oracleace
Facebook.com/oracleaces
oracle-ace_ww@oracle.com
Copyright © 2016 Accenture All rights reserved. | 6
SQL TUNING 101
Before start….
Copyright © 2016 Accenture All rights reserved. | 7
ORACLE DATABASE MULTILINGUAL ENGINE – BETA 12.2
Initial beta with JavaScript Stored Procedures
http://www.oracle.com/technetwork/database/multiling
ual-engine/overview/index.html
Copyright © 2016 Accenture All rights reserved. | 8
ORACLE DATABASE MULTILINGUAL ENGINE – BETA 12.2
Copyright © 2016 Accenture All rights reserved. | 9
ORACLE DATABASE MULTILINGUAL ENGINE – BETA 12.2
Copyright © 2016 Accenture All rights reserved. | 10
ORACLE DATABASE MULTILINGUAL ENGINE – BETA 12.2
http://www.oracle.com/technetwork/pt/articles/database-
performance/odb-12-2-multilingual-4394909-ptb.html
Copyright © 2016 Accenture All rights reserved. | 11
https://livesql.oracle.com
Copyright © 2016 Accenture All rights reserved. | 12
Copyright © 2016 Accenture All rights reserved. | 13
OVERVIEW
Database Tuning
Vs
SQL Tuning
Copyright © 2016 Accenture All rights reserved. | 14
OVERVIEW
Developers
vs
SQL
Copyright © 2016 Accenture All rights reserved. | 15
TOM KYTE
Copyright © 2016 Accenture All rights reserved. | 16
SQL TUNING 101
Let’s begin….
Copyright © 2016 Accenture All rights reserved. | 17
SQL TUNING 101
The application is running slow today!
Nothing has changed!
Copyright © 2016 Accenture All rights reserved. | 18
YES, SOMETHING HAS CHANGED
• Database upgraded
• Statistics gathered (automatic?)
• Schema changed
• Database parameter changed
• Application changed
• Operating system (OS) and hardware changed
• Data volume changed
• More active users
Copyright © 2016 Accenture All rights reserved. | 19
HOW TO START TROUBLESHOOTING?
One SQL?
All the database?
ASH and AWR
**Requires Oracle Diagnostics Pack
Copyright © 2016 Accenture All rights reserved. | 20
SQL TUNING
Proactive
Copyright © 2016 Accenture All rights reserved. | 21
SQL TUNING
Reactive
Copyright © 2016 Accenture All rights reserved. | 22
PROACTIVE – TOOLS
Copyright © 2016 Accenture All rights reserved. | 23
EDB360 - TOP SQLS
Copyright © 2016 Accenture All rights reserved. | 24
EDB360 - TOP EVENTS
Copyright © 2016 Accenture All rights reserved. | 25
EDB360
DEMO
Copyright © 2016 Accenture All rights reserved. | 26
AWR REPORT
• SQL ordered by Elapsed Time
• SQL ordered by CPU Time
• SQL ordered by User I/O Wait Time
• SQL ordered by Gets
• SQL ordered by Reads
• SQL ordered by Physical Reads (UnOptimized)
• SQL ordered by Executions
• SQL ordered by Parse Calls
• SQL ordered by Sharable Memory
• SQL ordered by Version Count
• SQL ordered by Cluster Wait Time
Copyright © 2016 Accenture All rights reserved. | 27
AWR REPORT
DEMO
Copyright © 2016 Accenture All rights reserved. | 28
REACTIVE - TOOLS
Copyright © 2016 Accenture All rights reserved. | 29
SQLT (SQLTXPLAIN) DIAGNOSTIC TOOL
(DOC ID 215187.1)
• Pros: Supported by Oracle
• Cons: Requires Installation
Copyright © 2016 Accenture All rights reserved. | 30
SQLT (SQLTXPLAIN) DIAGNOSTIC TOOL
(DOC ID 215187.1)
Copyright © 2016 Accenture All rights reserved. | 31
SQLD360
• Pros: No Installation
• Cons: Might miss some information
under rare circumstances
Copyright © 2016 Accenture All rights reserved. | 32
SQLTXPLAIN VS SQLD360
https://mauro-pagano.com/2017/04/29/sqltxplain-vs-sqld360-differences-and-similarities/
Copyright © 2016 Accenture All rights reserved. | 33
SQLD360 – HOW TO USE
• Download the free tool:
https://github.com/mauropagano/sqld360/
• Execution:
SQL> sqld360.sql <sql_id> [N|D|T]
Copyright © 2016 Accenture All rights reserved. | 34
SQLD360
Copyright © 2016 Accenture All rights reserved. | 35
SQLD360
Copyright © 2016 Accenture All rights reserved. | 36
SQLD360
Copyright © 2016 Accenture All rights reserved. | 37
SQLD360
Copyright © 2016 Accenture All rights reserved. | 38
SQLD360
DEMO
Copyright © 2016 Accenture All rights reserved. | 39
SQLD360
If you want to know more:
https://mauro-pagano.com/category/sqld360/
Copyright © 2016 Accenture All rights reserved. | 40
EXPLAIN PLAN
How about Explain Plan?
Copyright © 2016 Accenture All rights reserved. | 41
EXPLAIN PLAN
Explain Plain lies!
Copyright © 2016 Accenture All rights reserved. | 42
EXPLAIN PLAN
It does not actually execute the SQL statement.
Runtime factors can influence choice of plan:
• Dynamic Sampling
• Bind Variable Peeking
• Adaptive Features
Copyright © 2016 Accenture All rights reserved. | 43
NOW WHAT?
• DBMS_XPLAN.DISPLAY_CURSOR
• V$SQL_PLAN%
Copyright © 2016 Accenture All rights reserved. | 44
DBMS_XPLAN.DISPLAY_CURSOR
• SQL_ID
• CURSOR_CHILD_NO (default 0)
• FORMAT
TYPICAL = DEFAULT
ALL = TYPICAL + QB + PROJECTION + ALIAS + REMOTE
ADVANCED = ALL + OUTLINE + BINDS
ALLSTATS = IOSTATS + MEMSTATS (all executions)
ALLSTATS LAST (last execution)
ADAPTIVE (12c)
Copyright © 2016 Accenture All rights reserved. |
DBMS_XPLAN
Copyright © 2016 Accenture All rights reserved. |
DBMS_XPLAN
Display plan for the last SQL executed:
select * from table(dbms_xplan.display_cursor());
Copyright © 2016 Accenture All rights reserved. |
DBMS_XPLAN
Display plan for one specific SQL
• Get SQL_ID:
Copyright © 2016 Accenture All rights reserved. |
SQL_ID - 18C
Copyright © 2016 Accenture All rights reserved. |
DBMS_XPLAN
Copyright © 2016 Accenture All rights reserved. | 50
DBMS_XPLAN
DEMO
Copyright © 2016 Accenture All rights reserved. |
DBMS_XPLAN
Child Number ?
Copyright © 2016 Accenture All rights reserved. | 52
DBMS_XPLAN
DEMO
Copyright © 2016 Accenture All rights reserved. |https://blogs.oracle.com/optimizer/entry/how_do_i_know_if
/*+ gather_plan_statistics */
or
Alter session set statistics_level = ALL
ESTIMATE VS ACTUAL
Copyright © 2016 Accenture All rights reserved. | 54
ESTIMATE VS ACTUAL
DEMO
Copyright © 2016 Accenture All rights reserved. |
SQL MONITOR
• Introduced in Oracle Database 11g.
• Automatically started when a SQL statement either runs
in parallel or has consumed at least 5 seconds of
combined CPU and I/O.
• Hint /*+ MONITOR */
Copyright © 2016 Accenture All rights reserved. |
SQL MONITOR
• Oracle Enterprise Manager
• EM Database Express (12c)
• SQL Developer
• Command Line
**Part of the Oracle Tuning Pack
Copyright © 2016 Accenture All rights reserved. |
SQL MONITOR
select dbms_sqltune.report_sql_monitor(
sql_id => 'gjabwvvr07w09',
report_level=>'ALL',
type => 'ACTIVE') from dual;
Copyright © 2016 Accenture All rights reserved. |
SQL MONITOR
Copyright © 2016 Accenture All rights reserved. |
SQL MONITOR
Copyright © 2016 Accenture All rights reserved. | 60
DEMO
SQL MONITOR
Copyright © 2016 Accenture All rights reserved. | 61
COST OF AN INDEX
Copyright © 2016 Accenture All rights reserved. |
FULL TABLE SCAN
https://www.slideshare.net/MauroPagano3/full-table-scan-friend-or-foe
Copyright © 2016 Accenture All rights reserved. |
FULL TABLE SCAN
https://www.slideshare.net/MauroPagano3/full-table-scan-friend-or-foe
Copyright © 2016 Accenture All rights reserved. |
FULL TABLE SCAN
https://richardfoote.wordpress.com/2008/05/12/index-scan-or-full-table-scan-the-magic-number-magic-dance/
Copyright © 2016 Accenture All rights reserved. |
FULL TABLE SCAN
• Clustering Factor --> How well ordered the
rows in the table are in relation to the index.
• Selectivity of the query
• Number of table blocks
• Effective multiblock read count
• Relative cost of single vs. multiblock I/Os
• Parallelism
• Etc
Copyright © 2016 Accenture All rights reserved. |
FULL TABLE SCAN
https://www.slideshare.net/MauroPagano3/full-table-scan-friend-or-foe
Copyright © 2016 Accenture All rights reserved. | 67
• Not always good
• Not always bad
FULL TABLE SCAN
Copyright © 2016 Accenture All rights reserved. | 68
ANALYZING TABLES
Copyright © 2016 Accenture All rights reserved. | 69
ANALYZING TABLES
https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_4005.htm
Copyright © 2016 Accenture All rights reserved. | 70
ROW-BY-ROW PROCESSING
https://blog.jooq.org/2018/04/19/the-performance-difference-between-sql-row-by-row-updating-batch-updating-and-bulk-updating/
Copyright © 2016 Accenture All rights reserved. | 71
ROW-BY-ROW
Copyright © 2016 Accenture All rights reserved. | 72
ROW-BY-ROW
Copyright © 2016 Accenture All rights reserved. | 73
PL/SQL FORALL
Copyright © 2016 Accenture All rights reserved. | 74
ONE UPDATE
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
ALTER SESSION SET EVENTS '10053 trace
name context forever, level 1';
SELECT * FROM EMP WHERE ENAME = 'SCOTT';
ALTER SESSION SET EVENTS '10053 trace
name context off';
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
Level 1 or Level 2?
1. Parameters used by the optimizer (level 1 only)
2. Index statistics (level 1 only)
3. Column statistics
4. Single Access Paths
5. Join Costs
6. Table Joins Considered
7. Join Methods Considered (NL/MS/HA)
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
For another session:
SYS.DBMS_SYSTEM.SET_EV (SID,SERIAL ,10053,1)
Disable:
SYS.DBMS_SYSTEM.SET_EV (SID,SERIAL ,10053,0)
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
11G R1
ALTER SESSION SET EVENTS
'trace[rdbms.SQL_Optimizer.*][sql:my_sql_id]';
ALTER SESSION SET EVENTS
'trace[rdbms.SQL_Optimizer.*] off';
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
11G R2 – 18c
dbms_sqldiag.dump_trace(
p_sql_id=>’92c3fw9svc3rc’,
p_child_number=>0,
p_component=>'Compiler',
p_file_id=>’MY_Trace_File');
** Doesn’t require you to re-execute the statement.
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
ALTER SESSION SET EVENTS '10053 trace name
context forever, level 1';
SELECT * FROM tb_master p
WHERE EXISTS (SELECT 1 FROM tb_detail f
WHERE f.id_master=p.id);
ALTER SESSION SET EVENTS '10053 trace name
context off';
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
QUERY BLOCK – 2 parts
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
Parallelism - Disabled
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
Subtitles
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
Database Parameters
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
System Statistics
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
No statistics for these tables
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
Dynamic Sampling
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
Full Table Scan – No Index
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
Original: Final:
Final Query
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
Final Plan
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
Example 2
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053 Let’s run this one
Copyright © 2016 Accenture All rights reserved. |
EVENT 10053
Original:
Final:
Copyright © 2016 Accenture All rights reserved. | 98
Query Transformations
EVENT 10053
Copyright © 2016 Accenture All rights reserved. |
OR EXPANSION
Original:
SELECT * FROM emp
WHERE job = 'CLERK' OR deptno = 10;
Changed:
SELECT * FROM emp
WHERE job = 'CLERK’
UNION ALL
SELECT * FROM emp
WHERE deptno = 10 AND job <> 'CLERK';
Copyright © 2016 Accenture All rights reserved. |
SUBQUERY UNNESTING
Original:
SELECT * FROM accounts
WHERE custno IN
(SELECT custno FROM customers);
Changed:
SELECT accounts.*
FROM accounts, customers
WHERE accounts.custno = customers.custno;
Copyright © 2016 Accenture All rights reserved. |
VIEW MERGING
Original:
CREATE VIEW emp_10 AS
SELECT empno, ename, job, sal, comm, deptno
FROM emp
WHERE deptno = 10;
SELECT empno FROM emp_10
WHERE empno > 7800;
Changed:
SELECT empno
FROM emp
WHERE deptno = 10 AND empno > 7800;
Copyright © 2016 Accenture All rights reserved. |
PREDICATE PUSHING
Original:
CREATE VIEW two_emp_tables AS
SELECT empno, ename, job, sal, comm, deptno
FROM emp1
UNION
SELECT empno, ename, job, sal, comm, deptno
FROM emp2;
SELECT ename FROM two_emp_tables
WHERE deptno = 20;
Copyright © 2016 Accenture All rights reserved. |
PREDICATE PUSHING
Changed:
SELECT ename
FROM ( SELECT empno, ename, job,sal, comm, deptno
FROM emp1 WHERE deptno = 20
UNION
SELECT empno, ename, job,sal, comm, deptno
FROM emp2 WHERE deptno = 20 );
Copyright © 2016 Accenture All rights reserved. |
TRANSITIVITY
Original:
SELECT *
FROM emp, dept
WHERE emp.deptno = 20
AND emp.deptno = dept.deptno;
Changed:
SELECT *
FROM emp, dept
WHERE emp.deptno = 20
AND emp.deptno = dept.deptno
AND dept.deptno = 20;
Copyright © 2016 Accenture All rights reserved. | 105
COUNT(1) VS COUNT(*)
What is the difference between count(1) and count(*) ?
Copyright © 2016 Accenture All rights reserved. | 106
COUNT(1) VS COUNT(*)
Nothing
Copyright © 2016 Accenture All rights reserved. | 107
COUNT(1) VS COUNT(*)
Copyright © 2016 Accenture All rights reserved. |
MORE ABOUT THE EVENT 10053
Copyright © 2016 Accenture All rights reserved. |
Copyright © 2016 Accenture All rights reserved. |
Oracle Database 12.1
OPTIMIZER_ADAPTIVE_FEATURES
Default TRUE
ADAPTIVE FEATURES
Copyright © 2016 Accenture All rights reserved. |
Oracle Database 12.2 introduces the new split-
up adaptive parameters:
• OPTIMIZER_ADAPTIVE_PLANS
• OPTIMITER_ADAPTIVE_STATISTICS
ADAPTIVE FEATURES
Copyright © 2016 Accenture All rights reserved. |
On Oracle Database 12.1 this can be achieved
by installing two patches.
ADAPTIVE FEATURES
Copyright © 2016 Accenture All rights reserved. |
The patch for bug# 22652097 introduces the two parameters
OPTIMIZER_ADAPTIVE_PLANS and
OPTIMIZER_ADAPTIVE_STATISTICS, and in addition removes
the parameter OPTIMIZER_ADAPTIVE_FEATURES.
The patch for bug# 21171382 disables the automatic creation of
extended statistics unless the optimizer preference
AUTO_STATS_EXTENSIONS is set to ON.
ADAPTIVE FEATURES
Copyright © 2016 Accenture All rights reserved. |
https://blogs.oracle.com/optimizer/entry/improvement_of_auto_sampling_statistics_gathering_feature_in_oracle_database_11g
estimate_percent => dbms_stats.auto_sample_size
STATISTICS
Copyright © 2016 Accenture All rights reserved. |
Should I use?
HINTS
Copyright © 2016 Accenture All rights reserved. |
Query running on M7: 180 Minutes
Query after db clone  P8+Storage ?
• Time: 29 hours
Query running on M7 after SQL tuning: 17 minutes
SQL TUNING ON EXADATA
Copyright © 2016 Accenture All rights reserved. |
SQL TUNING ON EXADATA
Copyright © 2016 Accenture All rights reserved. |
Copyright © 2016 Accenture All rights reserved. |
Set table preferences:
begin
dbms_stats.set_table_prefs (
ownname => 'SCOTT',
tabname => 'EMP',
pname => 'PUBLISH',
pvalue => 'FALSE'
);
end;
Collect the statistics.
PENDING STATISTICS
Copyright © 2016 Accenture All rights reserved. |
select num_rows,
to_char(last_analyzed,'dd/mm/rrrr hh24:mi:ss’)
from all_tab_pending_stats
where table_name = 'EMP';
PENDING STATISTICS
Copyright © 2016 Accenture All rights reserved. |
alter session set
optimizer_use_pending_statistics = true;
Test your queries.
PENDING STATISTICS
Copyright © 2016 Accenture All rights reserved. |
If it’s ok:
dbms_stats.publish_pending_stats('SCOTT', 'EMP’);
or:
dbms_stats.delete_pending_stats(’SCOTT',’EMP');
PENDING STATISTICS
Copyright © 2016 Accenture All rights reserved. |
Check the retention:
select DBMS_STATS.GET_STATS_HISTORY_RETENTION from dual;
Default is 31 days.
RESTORE STATISTICS FROM HISTORY
Copyright © 2016 Accenture All rights reserved. |
Statistics available for the table:
SELECT OWNER,
TABLE_NAME,
STATS_UPDATE_TIME
FROM dba_tab_stats_history
WHERE table_name='MY_TABLE';
RESTORE STATISTICS FROM HISTORY
Copyright © 2016 Accenture All rights reserved. |
Begin
dbms_stats.restore_table_stats(
'SCOTT',
'EMP',
‘08-NOV-16 11.38.05.015640 AM +08:00’);
End;
RESTORE STATISTICS FROM HISTORY
Copyright © 2016 Accenture All rights reserved. |
begin
dbms_stats.CREATE_STAT_TABLE( ownname=>user
, stattab=>'MY_STATS_TABLE'
);
end;
begin
dbms_stats.export_schema_stats( ownname=>user
, stattab=>'MY_STATS_TABLE'
, statid=>'CURRENT_STATS'
);
end;
EXPORT AND IMPORT SCHEMA STATISTICS
Copyright © 2016 Accenture All rights reserved. |
EXPDP / IMPDP
begin
dbms_stats.import_schema_stats( ownname=>user
, stattab=>'MY_STATS_TABLE'
, statid=>'CURRENT_STATS'
);
End;
EXPORT AND IMPORT SCHEMA STATISTICS
Copyright © 2016 Accenture All rights reserved. |
Incremental statistics for partitioned tables:
dbms_stats.set_table_prefs(null,'SALES','INCREMENTAL','TRUE')
INCREMENTAL STATISTICS
Copyright © 2016 Accenture All rights reserved. |
INCREMENTAL STATISTICS
Copyright © 2016 Accenture All rights reserved. |
CREATE INDEX index_name ON
table_name(column_name) INVISIBLE;
ALTER INDEX index_name INVISIBLE;
ALTER INDEX index_name VISIBLE;
INVISIBLE INDEXES
Copyright © 2016 Accenture All rights reserved. |
ALTER SESSION SET
OPTIMIZER_USE_INVISIBLE_INDEXES=TRUE;
INVISIBLE INDEXES
Copyright © 2016 Accenture All rights reserved. |
ALTER SESSION SET sql_trace=TRUE;
ALTER SESSION SET sql_trace=FALSE;
EXEC DBMS_SESSION.set_sql_trace(sql_trace => TRUE);
EXEC DBMS_SESSION.set_sql_trace(sql_trace => FALSE);
ALTER SESSION SET EVENTS '10046 trace name context forever, level 12';
ALTER SESSION SET EVENTS '10046 trace name context off';
EXEC DBMS_SYSTEM.set_sql_trace_in_session(sid=>0000, serial#=>0000, sql_trace=>TRUE);
EXEC DBMS_SYSTEM.set_sql_trace_in_session(sid=>0000, serial#=>0000, sql_trace=>FALSE);
SQL TRACE, 10046, TRCSESS AND TKPROF
Copyright © 2016 Accenture All rights reserved. |
CONN sys/password AS SYSDBA;
ORADEBUG SETMYPID;
ORADEBUG SETOSPID 0000;
ORADEBUG SETORAPID 000000;
ORADEBUG EVENT 10046 TRACE NAME CONTEXT FOREVER, LEVEL 12;
ORADEBUG EVENT 10046 TRACE NAME CONTEXT OFF;
SQL TRACE, 10046, TRCSESS AND TKPROF
Copyright © 2016 Accenture All rights reserved. |
EXEC DBMS_SUPPORT.start_trace(waits=>TRUE, binds=>TRUE);
EXEC DBMS_SUPPORT.stop_trace;
EXEC DBMS_SUPPORT.start_trace_in_session(sid=>0000, serial=>000000, waits=>TRUE,
binds=>TRUE);
EXEC DBMS_SUPPORT.stop_trace_in_session(sid=>0000, serial=>000000);
SQL TRACE, 10046, TRCSESS AND TKPROF
Copyright © 2016 Accenture All rights reserved. |
10g:
DBMS_MONITOR.session_trace_enable(waits=>TRUE, binds=>FALSE);
DBMS_MONITOR.session_trace_enable(session_id =>0000, serial_num=>000000,
waits=>TRUE, binds=>TRUE);
DBMS_MONITOR.client_id_trace_enable(client_id=>'my_client', waits=>TRUE,
binds=>TRUE);
DBMS_MONITOR.serv_mod_act_trace_enable(service_name=>'my_srv',
module_name=>'my_test', action_name=>'calculating', waits=>TRUE,
binds=>TRUE);
SQL TRACE, 10046, TRCSESS AND TKPROF
Copyright © 2016 Accenture All rights reserved. |
ALTER SESSION SET TRACEFILE_IDENTIFIER = "MY_TRC_FILE";
SQL TRACE, 10046, TRCSESS AND TKPROF
Copyright © 2016 Accenture All rights reserved. |
SELECT p.tracefile
FROM v$session s
JOIN v$process p
ON s.paddr = p.addr
WHERE s.sid = MY_SID;
SQL TRACE, 10046, TRCSESS AND TKPROF
Copyright © 2016 Accenture All rights reserved. |
12.2
v$diag_trace_file
v$diag_trace_file_contents
SQL TRACE, 10046, TRCSESS AND TKPROF
Copyright © 2016 Accenture All rights reserved. |
EVENT 10046
Copyright © 2016 Accenture All rights reserved. |
ALTER SESSION SET EVENTS '10046 trace name
context forever, level 12';
SELECT * FROM tb_pai p
WHERE EXISTS (SELECT 1 FROM tb_filho f
WHERE f.id_pai=p.id);
ALTER SESSION SET EVENTS '10046 trace name
context off';
EVENT 10046
Copyright © 2016 Accenture All rights reserved. |
EVENT 10046
Copyright © 2016 Accenture All rights reserved. |
EVENT 10046
Copyright © 2016 Accenture All rights reserved. |
EVENT 10046
Copyright © 2016 Accenture All rights reserved. |
EVENT 10046
Copyright © 2016 Accenture All rights reserved. |
EVENT 10046
Copyright © 2016 Accenture All rights reserved. |
EVENT 10046
Copyright © 2016 Accenture All rights reserved. |
• TKPROF
• TRCSESS
• Trace Analyzer TRCANLZR (TRCA)
• Method R Tools
SQL TRACE, 10046, TRCSESS AND TKPROF
Copyright © 2016 Accenture All rights reserved. |
SQL TRACE, 10046, TRCSESS AND
TKPROF
Copyright © 2016 Accenture All rights reserved. |http://www.oraclenerd.com/2011/02/sql-developer-mr-trace.html
SQL TRACE, 10046, TRCSESS AND TKPROF
Copyright © 2016 Accenture All rights reserved. | 150
SQLCL
http://www.oracle.com/technetwork/developer-tools/sqlcl/downloads/index.html
Copyright © 2016 Accenture All rights reserved. | 151
QUESTIONS?
Copyright © 2016 Accenture All rights reserved. | 152
Thank You
Slides Available: http://www.slideshare.net/

Más contenido relacionado

La actualidad más candente

COUG_AAbate_Oracle_Database_12c_New_Features
COUG_AAbate_Oracle_Database_12c_New_FeaturesCOUG_AAbate_Oracle_Database_12c_New_Features
COUG_AAbate_Oracle_Database_12c_New_FeaturesAlfredo Abate
 
Haute Disponibilité et Reprise sur incidents en SharePoint 2013 avec Sql Serv...
Haute Disponibilité et Reprise sur incidents en SharePoint 2013 avec Sql Serv...Haute Disponibilité et Reprise sur incidents en SharePoint 2013 avec Sql Serv...
Haute Disponibilité et Reprise sur incidents en SharePoint 2013 avec Sql Serv...serge luca
 
Oracle Management Cloud - introduction, overview and getting started (AMIS, 2...
Oracle Management Cloud - introduction, overview and getting started (AMIS, 2...Oracle Management Cloud - introduction, overview and getting started (AMIS, 2...
Oracle Management Cloud - introduction, overview and getting started (AMIS, 2...Lucas Jellema
 
#GeodeSummit - Apex & Geode: In-memory streaming, storage & analytics
#GeodeSummit - Apex & Geode: In-memory streaming, storage & analytics#GeodeSummit - Apex & Geode: In-memory streaming, storage & analytics
#GeodeSummit - Apex & Geode: In-memory streaming, storage & analyticsPivotalOpenSourceHub
 
Data Estate Modernization
Data Estate ModernizationData Estate Modernization
Data Estate ModernizationIndra Dharmawan
 
EBS on Oracle Cloud
EBS on Oracle CloudEBS on Oracle Cloud
EBS on Oracle Cloudvasuballa
 
Change Management for Oracle Database with SQLcl
Change Management for Oracle Database with SQLcl Change Management for Oracle Database with SQLcl
Change Management for Oracle Database with SQLcl Jeff Smith
 
REST Enabling your Oracle Database (2018 Update)
REST Enabling your Oracle Database (2018 Update)REST Enabling your Oracle Database (2018 Update)
REST Enabling your Oracle Database (2018 Update)Jeff Smith
 
Migration to Modern SQL Server Platform
Migration to Modern SQL Server PlatformMigration to Modern SQL Server Platform
Migration to Modern SQL Server PlatformIndra Dharmawan
 
Whats new in oracle orachk & exachk 12.2.0.1.4
Whats new in oracle orachk & exachk 12.2.0.1.4Whats new in oracle orachk & exachk 12.2.0.1.4
Whats new in oracle orachk & exachk 12.2.0.1.4Gareth Chapman
 
OOW16 - Oracle Enterprise Manager 13c Cloud Control for Managing Oracle E-Bus...
OOW16 - Oracle Enterprise Manager 13c Cloud Control for Managing Oracle E-Bus...OOW16 - Oracle Enterprise Manager 13c Cloud Control for Managing Oracle E-Bus...
OOW16 - Oracle Enterprise Manager 13c Cloud Control for Managing Oracle E-Bus...vasuballa
 
Oasis – data analysis platform for enterprise
Oasis – data analysis platform for enterpriseOasis – data analysis platform for enterprise
Oasis – data analysis platform for enterpriseLINE Corporation
 
QA standup - workload analysis
QA standup  - workload analysisQA standup  - workload analysis
QA standup - workload analysisSerghei Radov
 
Monitoring Always On Avaliability Group
Monitoring Always On Avaliability GroupMonitoring Always On Avaliability Group
Monitoring Always On Avaliability GroupSourabh Agarwal
 
Accumulo Summit 2016: Effective Testing of Apache Accumulo Iterators
Accumulo Summit 2016: Effective Testing of Apache Accumulo IteratorsAccumulo Summit 2016: Effective Testing of Apache Accumulo Iterators
Accumulo Summit 2016: Effective Testing of Apache Accumulo IteratorsAccumulo Summit
 
Oracle SQL Developer: 3 Features You're Not Using But Should Be
Oracle SQL Developer: 3 Features You're Not Using But Should BeOracle SQL Developer: 3 Features You're Not Using But Should Be
Oracle SQL Developer: 3 Features You're Not Using But Should BeJeff Smith
 
Writing Apache Spark and Apache Flink Applications Using Apache Bahir
Writing Apache Spark and Apache Flink Applications Using Apache BahirWriting Apache Spark and Apache Flink Applications Using Apache Bahir
Writing Apache Spark and Apache Flink Applications Using Apache BahirLuciano Resende
 
SparkOscope: Enabling Apache Spark Optimization through Cross Stack Monitorin...
SparkOscope: Enabling Apache Spark Optimization through Cross Stack Monitorin...SparkOscope: Enabling Apache Spark Optimization through Cross Stack Monitorin...
SparkOscope: Enabling Apache Spark Optimization through Cross Stack Monitorin...Databricks
 
Sql 2012 Upgrade Readiness Guide
Sql 2012 Upgrade Readiness GuideSql 2012 Upgrade Readiness Guide
Sql 2012 Upgrade Readiness GuidePARIKSHIT SAVJANI
 
How to Upgrade Hundreds or Thousands of Databases
How to Upgrade Hundreds or Thousands of DatabasesHow to Upgrade Hundreds or Thousands of Databases
How to Upgrade Hundreds or Thousands of DatabasesDLT Solutions
 

La actualidad más candente (20)

COUG_AAbate_Oracle_Database_12c_New_Features
COUG_AAbate_Oracle_Database_12c_New_FeaturesCOUG_AAbate_Oracle_Database_12c_New_Features
COUG_AAbate_Oracle_Database_12c_New_Features
 
Haute Disponibilité et Reprise sur incidents en SharePoint 2013 avec Sql Serv...
Haute Disponibilité et Reprise sur incidents en SharePoint 2013 avec Sql Serv...Haute Disponibilité et Reprise sur incidents en SharePoint 2013 avec Sql Serv...
Haute Disponibilité et Reprise sur incidents en SharePoint 2013 avec Sql Serv...
 
Oracle Management Cloud - introduction, overview and getting started (AMIS, 2...
Oracle Management Cloud - introduction, overview and getting started (AMIS, 2...Oracle Management Cloud - introduction, overview and getting started (AMIS, 2...
Oracle Management Cloud - introduction, overview and getting started (AMIS, 2...
 
#GeodeSummit - Apex & Geode: In-memory streaming, storage & analytics
#GeodeSummit - Apex & Geode: In-memory streaming, storage & analytics#GeodeSummit - Apex & Geode: In-memory streaming, storage & analytics
#GeodeSummit - Apex & Geode: In-memory streaming, storage & analytics
 
Data Estate Modernization
Data Estate ModernizationData Estate Modernization
Data Estate Modernization
 
EBS on Oracle Cloud
EBS on Oracle CloudEBS on Oracle Cloud
EBS on Oracle Cloud
 
Change Management for Oracle Database with SQLcl
Change Management for Oracle Database with SQLcl Change Management for Oracle Database with SQLcl
Change Management for Oracle Database with SQLcl
 
REST Enabling your Oracle Database (2018 Update)
REST Enabling your Oracle Database (2018 Update)REST Enabling your Oracle Database (2018 Update)
REST Enabling your Oracle Database (2018 Update)
 
Migration to Modern SQL Server Platform
Migration to Modern SQL Server PlatformMigration to Modern SQL Server Platform
Migration to Modern SQL Server Platform
 
Whats new in oracle orachk & exachk 12.2.0.1.4
Whats new in oracle orachk & exachk 12.2.0.1.4Whats new in oracle orachk & exachk 12.2.0.1.4
Whats new in oracle orachk & exachk 12.2.0.1.4
 
OOW16 - Oracle Enterprise Manager 13c Cloud Control for Managing Oracle E-Bus...
OOW16 - Oracle Enterprise Manager 13c Cloud Control for Managing Oracle E-Bus...OOW16 - Oracle Enterprise Manager 13c Cloud Control for Managing Oracle E-Bus...
OOW16 - Oracle Enterprise Manager 13c Cloud Control for Managing Oracle E-Bus...
 
Oasis – data analysis platform for enterprise
Oasis – data analysis platform for enterpriseOasis – data analysis platform for enterprise
Oasis – data analysis platform for enterprise
 
QA standup - workload analysis
QA standup  - workload analysisQA standup  - workload analysis
QA standup - workload analysis
 
Monitoring Always On Avaliability Group
Monitoring Always On Avaliability GroupMonitoring Always On Avaliability Group
Monitoring Always On Avaliability Group
 
Accumulo Summit 2016: Effective Testing of Apache Accumulo Iterators
Accumulo Summit 2016: Effective Testing of Apache Accumulo IteratorsAccumulo Summit 2016: Effective Testing of Apache Accumulo Iterators
Accumulo Summit 2016: Effective Testing of Apache Accumulo Iterators
 
Oracle SQL Developer: 3 Features You're Not Using But Should Be
Oracle SQL Developer: 3 Features You're Not Using But Should BeOracle SQL Developer: 3 Features You're Not Using But Should Be
Oracle SQL Developer: 3 Features You're Not Using But Should Be
 
Writing Apache Spark and Apache Flink Applications Using Apache Bahir
Writing Apache Spark and Apache Flink Applications Using Apache BahirWriting Apache Spark and Apache Flink Applications Using Apache Bahir
Writing Apache Spark and Apache Flink Applications Using Apache Bahir
 
SparkOscope: Enabling Apache Spark Optimization through Cross Stack Monitorin...
SparkOscope: Enabling Apache Spark Optimization through Cross Stack Monitorin...SparkOscope: Enabling Apache Spark Optimization through Cross Stack Monitorin...
SparkOscope: Enabling Apache Spark Optimization through Cross Stack Monitorin...
 
Sql 2012 Upgrade Readiness Guide
Sql 2012 Upgrade Readiness GuideSql 2012 Upgrade Readiness Guide
Sql 2012 Upgrade Readiness Guide
 
How to Upgrade Hundreds or Thousands of Databases
How to Upgrade Hundreds or Thousands of DatabasesHow to Upgrade Hundreds or Thousands of Databases
How to Upgrade Hundreds or Thousands of Databases
 

Similar a SQL TUNING 101

DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowDBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowDBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
LET’S GET STARTED WITH ORACLE DATABASE CLOUD
LET’S GET STARTED WITH ORACLE DATABASE CLOUDLET’S GET STARTED WITH ORACLE DATABASE CLOUD
LET’S GET STARTED WITH ORACLE DATABASE CLOUDAlex Zaballa
 
EXAchk for Exadata Presentation
EXAchk for Exadata PresentationEXAchk for Exadata Presentation
EXAchk for Exadata PresentationSandesh Rao
 
MySQL Enterprise Monitor
MySQL Enterprise MonitorMySQL Enterprise Monitor
MySQL Enterprise MonitorMario Beck
 
Migrating Oracle Databases from AWS to OCI
Migrating Oracle Databases from AWS to OCIMigrating Oracle Databases from AWS to OCI
Migrating Oracle Databases from AWS to OCIAlex Zaballa
 
The Oracle Autonomous Database
The Oracle Autonomous DatabaseThe Oracle Autonomous Database
The Oracle Autonomous DatabaseConnor McDonald
 
Oracle Management Cloud - HybridCloud Café - May 2016
Oracle Management Cloud - HybridCloud Café - May 2016Oracle Management Cloud - HybridCloud Café - May 2016
Oracle Management Cloud - HybridCloud Café - May 2016Bastien Leblanc
 
Oracle Cloud Café hybrid Cloud 19 mai 2016
Oracle Cloud Café hybrid Cloud 19 mai 2016Oracle Cloud Café hybrid Cloud 19 mai 2016
Oracle Cloud Café hybrid Cloud 19 mai 2016Sorathaya Sirimanotham
 
C5 journey to_the_cloud_with_oracle_sparc
C5 journey to_the_cloud_with_oracle_sparcC5 journey to_the_cloud_with_oracle_sparc
C5 journey to_the_cloud_with_oracle_sparcDr. Wilfred Lin (Ph.D.)
 
Exploring All options to move your Oracle Databases to the Oracle Cloud
Exploring All options to move your Oracle Databases to the Oracle CloudExploring All options to move your Oracle Databases to the Oracle Cloud
Exploring All options to move your Oracle Databases to the Oracle CloudAlex Zaballa
 
Moving Your Oracle Databases To The Oracle Cloud
Moving Your Oracle Databases To The Oracle CloudMoving Your Oracle Databases To The Oracle Cloud
Moving Your Oracle Databases To The Oracle CloudAlex Zaballa
 
Accenture at LiveWorx: Making Business Flow. Projects are the Anti-Patterns
Accenture at LiveWorx: Making Business Flow. Projects are the Anti-PatternsAccenture at LiveWorx: Making Business Flow. Projects are the Anti-Patterns
Accenture at LiveWorx: Making Business Flow. Projects are the Anti-Patternsaccenture
 
Explain the explain_plan
Explain the explain_planExplain the explain_plan
Explain the explain_planMaria Colgan
 
MySQL in oracle_environments(Part 2): MySQL Enterprise Monitor & Oracle Enter...
MySQL in oracle_environments(Part 2): MySQL Enterprise Monitor & Oracle Enter...MySQL in oracle_environments(Part 2): MySQL Enterprise Monitor & Oracle Enter...
MySQL in oracle_environments(Part 2): MySQL Enterprise Monitor & Oracle Enter...OracleMySQL
 
C4 optimizing your_application_infrastructure
C4 optimizing your_application_infrastructureC4 optimizing your_application_infrastructure
C4 optimizing your_application_infrastructureDr. Wilfred Lin (Ph.D.)
 
New Features in Oracle ORAchk & EXAchk 12.2.0.1.1
New Features in Oracle ORAchk & EXAchk 12.2.0.1.1New Features in Oracle ORAchk & EXAchk 12.2.0.1.1
New Features in Oracle ORAchk & EXAchk 12.2.0.1.1Gareth Chapman
 

Similar a SQL TUNING 101 (20)

DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowDBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should Know
 
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowDBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should Know
 
LET’S GET STARTED WITH ORACLE DATABASE CLOUD
LET’S GET STARTED WITH ORACLE DATABASE CLOUDLET’S GET STARTED WITH ORACLE DATABASE CLOUD
LET’S GET STARTED WITH ORACLE DATABASE CLOUD
 
Enterprise manager 13c
Enterprise manager 13cEnterprise manager 13c
Enterprise manager 13c
 
OEM13c_PPT.pptx
OEM13c_PPT.pptxOEM13c_PPT.pptx
OEM13c_PPT.pptx
 
EXAchk for Exadata Presentation
EXAchk for Exadata PresentationEXAchk for Exadata Presentation
EXAchk for Exadata Presentation
 
MySQL Enterprise Monitor
MySQL Enterprise MonitorMySQL Enterprise Monitor
MySQL Enterprise Monitor
 
Migrating Oracle Databases from AWS to OCI
Migrating Oracle Databases from AWS to OCIMigrating Oracle Databases from AWS to OCI
Migrating Oracle Databases from AWS to OCI
 
The Oracle Autonomous Database
The Oracle Autonomous DatabaseThe Oracle Autonomous Database
The Oracle Autonomous Database
 
Oracle Management Cloud - HybridCloud Café - May 2016
Oracle Management Cloud - HybridCloud Café - May 2016Oracle Management Cloud - HybridCloud Café - May 2016
Oracle Management Cloud - HybridCloud Café - May 2016
 
Oracle Cloud Café hybrid Cloud 19 mai 2016
Oracle Cloud Café hybrid Cloud 19 mai 2016Oracle Cloud Café hybrid Cloud 19 mai 2016
Oracle Cloud Café hybrid Cloud 19 mai 2016
 
C5 journey to_the_cloud_with_oracle_sparc
C5 journey to_the_cloud_with_oracle_sparcC5 journey to_the_cloud_with_oracle_sparc
C5 journey to_the_cloud_with_oracle_sparc
 
Exploring All options to move your Oracle Databases to the Oracle Cloud
Exploring All options to move your Oracle Databases to the Oracle CloudExploring All options to move your Oracle Databases to the Oracle Cloud
Exploring All options to move your Oracle Databases to the Oracle Cloud
 
Moving Your Oracle Databases To The Oracle Cloud
Moving Your Oracle Databases To The Oracle CloudMoving Your Oracle Databases To The Oracle Cloud
Moving Your Oracle Databases To The Oracle Cloud
 
Accenture at LiveWorx: Making Business Flow. Projects are the Anti-Patterns
Accenture at LiveWorx: Making Business Flow. Projects are the Anti-PatternsAccenture at LiveWorx: Making Business Flow. Projects are the Anti-Patterns
Accenture at LiveWorx: Making Business Flow. Projects are the Anti-Patterns
 
Explain the explain_plan
Explain the explain_planExplain the explain_plan
Explain the explain_plan
 
MySQL in oracle_environments(Part 2): MySQL Enterprise Monitor & Oracle Enter...
MySQL in oracle_environments(Part 2): MySQL Enterprise Monitor & Oracle Enter...MySQL in oracle_environments(Part 2): MySQL Enterprise Monitor & Oracle Enter...
MySQL in oracle_environments(Part 2): MySQL Enterprise Monitor & Oracle Enter...
 
AWR, ASH with EM13 at HotSos 2016
AWR, ASH with EM13 at HotSos 2016AWR, ASH with EM13 at HotSos 2016
AWR, ASH with EM13 at HotSos 2016
 
C4 optimizing your_application_infrastructure
C4 optimizing your_application_infrastructureC4 optimizing your_application_infrastructure
C4 optimizing your_application_infrastructure
 
New Features in Oracle ORAchk & EXAchk 12.2.0.1.1
New Features in Oracle ORAchk & EXAchk 12.2.0.1.1New Features in Oracle ORAchk & EXAchk 12.2.0.1.1
New Features in Oracle ORAchk & EXAchk 12.2.0.1.1
 

Más de Alex Zaballa

DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2Alex Zaballa
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsAlex Zaballa
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
Os melhores recursos novos do Oracle Database 12c para desenvolvedores e DBAs...
Os melhores recursos novos do Oracle Database 12c para desenvolvedores e DBAs...Os melhores recursos novos do Oracle Database 12c para desenvolvedores e DBAs...
Os melhores recursos novos do Oracle Database 12c para desenvolvedores e DBAs...Alex Zaballa
 
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowOTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Fea...
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Fea...OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Fea...
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Fea...Alex Zaballa
 
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c New Featur...
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c New Featur...OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c New Featur...
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c New Featur...Alex Zaballa
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...Alex Zaballa
 
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...Alex Zaballa
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Alex Zaballa
 
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowDBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
Oracle Data Redaction
Oracle Data RedactionOracle Data Redaction
Oracle Data RedactionAlex Zaballa
 
Oracle Database 12c - Novas Características para DBAs e Desenvolvedores
Oracle Database 12c - Novas Características para DBAs e DesenvolvedoresOracle Database 12c - Novas Características para DBAs e Desenvolvedores
Oracle Database 12c - Novas Características para DBAs e DesenvolvedoresAlex Zaballa
 
Oracle Data Redaction - EOUC
Oracle Data Redaction - EOUCOracle Data Redaction - EOUC
Oracle Data Redaction - EOUCAlex Zaballa
 
Oracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New FeaturesOracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New FeaturesAlex Zaballa
 
Oracle Database 12c - Data Redaction
Oracle Database 12c - Data RedactionOracle Database 12c - Data Redaction
Oracle Database 12c - Data RedactionAlex Zaballa
 
Oracle Database 12c - Novas Características para DBAs e Desenvolvedores - GUO...
Oracle Database 12c - Novas Características para DBAs e Desenvolvedores - GUO...Oracle Database 12c - Novas Características para DBAs e Desenvolvedores - GUO...
Oracle Database 12c - Novas Características para DBAs e Desenvolvedores - GUO...Alex Zaballa
 
Oracle Data redaction - GUOB - OTN TOUR LA - 2015
Oracle Data redaction - GUOB - OTN TOUR LA - 2015Oracle Data redaction - GUOB - OTN TOUR LA - 2015
Oracle Data redaction - GUOB - OTN TOUR LA - 2015Alex Zaballa
 

Más de Alex Zaballa (20)

DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2
 
Oracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAsOracle Database 12c - New Features for Developers and DBAs
Oracle Database 12c - New Features for Developers and DBAs
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
Os melhores recursos novos do Oracle Database 12c para desenvolvedores e DBAs...
Os melhores recursos novos do Oracle Database 12c para desenvolvedores e DBAs...Os melhores recursos novos do Oracle Database 12c para desenvolvedores e DBAs...
Os melhores recursos novos do Oracle Database 12c para desenvolvedores e DBAs...
 
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should KnowOTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
OTN TOUR 2016 - DBA Commands and Concepts That Every Developer Should Know
 
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Fea...
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Fea...OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Fea...
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Fea...
 
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c New Featur...
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c New Featur...OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c New Featur...
OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c New Featur...
 
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
 
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...
 
Oracle SQL Tuning
Oracle SQL TuningOracle SQL Tuning
Oracle SQL Tuning
 
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should KnowDBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
DBA Brasil 1.0 - DBA Commands and Concepts That Every Developer Should Know
 
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
 
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowDBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should Know
 
Oracle Data Redaction
Oracle Data RedactionOracle Data Redaction
Oracle Data Redaction
 
Oracle Database 12c - Novas Características para DBAs e Desenvolvedores
Oracle Database 12c - Novas Características para DBAs e DesenvolvedoresOracle Database 12c - Novas Características para DBAs e Desenvolvedores
Oracle Database 12c - Novas Características para DBAs e Desenvolvedores
 
Oracle Data Redaction - EOUC
Oracle Data Redaction - EOUCOracle Data Redaction - EOUC
Oracle Data Redaction - EOUC
 
Oracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New FeaturesOracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New Features
 
Oracle Database 12c - Data Redaction
Oracle Database 12c - Data RedactionOracle Database 12c - Data Redaction
Oracle Database 12c - Data Redaction
 
Oracle Database 12c - Novas Características para DBAs e Desenvolvedores - GUO...
Oracle Database 12c - Novas Características para DBAs e Desenvolvedores - GUO...Oracle Database 12c - Novas Características para DBAs e Desenvolvedores - GUO...
Oracle Database 12c - Novas Características para DBAs e Desenvolvedores - GUO...
 
Oracle Data redaction - GUOB - OTN TOUR LA - 2015
Oracle Data redaction - GUOB - OTN TOUR LA - 2015Oracle Data redaction - GUOB - OTN TOUR LA - 2015
Oracle Data redaction - GUOB - OTN TOUR LA - 2015
 

Último

Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8DianaGray10
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-pyJamie (Taka) Wang
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfDaniel Santiago Silva Capera
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsSeth Reyes
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...Aggregage
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarPrecisely
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding TeamAdam Moalla
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?IES VE
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXTarek Kalaji
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 

Último (20)

Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8
 
201610817 - edge part1
201610817 - edge part1201610817 - edge part1
201610817 - edge part1
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-py
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and Hazards
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity Webinar
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBX
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 

SQL TUNING 101

  • 2. Copyright © 2016 Accenture All rights reserved. | 2 Alex Zaballa http://alexzaballa.blogspot.com/ @alexzaballa https://www.linkedin.com/in/alexzaballa 275 and counting…
  • 3. Copyright © 2016 Accenture All rights reserved. | 3 Worked for 3 years in Brazil as a Clipper/Delphi Developer (15 years old) 1997-1999 Worked for 7 years in Brazil as an Oracle Developer 2000 - 2007 Worked for 8 years in Angola as an Oracle DBA for the Ministry of Finance. 2007 - 2015
  • 4. Copyright © 2016 Accenture All rights reserved. | 4
  • 5. Copyright © 2016 Accenture All rights reserved. | 5 3 Membership Tiers • Oracle ACE Director • Oracle ACE • Oracle ACE Associate bit.ly/OracleACEProgram 500+ Technical Experts Helping Peers Globally Connect: Nominate yourself or someone you know: acenomination.oracle.com @oracleace Facebook.com/oracleaces oracle-ace_ww@oracle.com
  • 6. Copyright © 2016 Accenture All rights reserved. | 6 SQL TUNING 101 Before start….
  • 7. Copyright © 2016 Accenture All rights reserved. | 7 ORACLE DATABASE MULTILINGUAL ENGINE – BETA 12.2 Initial beta with JavaScript Stored Procedures http://www.oracle.com/technetwork/database/multiling ual-engine/overview/index.html
  • 8. Copyright © 2016 Accenture All rights reserved. | 8 ORACLE DATABASE MULTILINGUAL ENGINE – BETA 12.2
  • 9. Copyright © 2016 Accenture All rights reserved. | 9 ORACLE DATABASE MULTILINGUAL ENGINE – BETA 12.2
  • 10. Copyright © 2016 Accenture All rights reserved. | 10 ORACLE DATABASE MULTILINGUAL ENGINE – BETA 12.2 http://www.oracle.com/technetwork/pt/articles/database- performance/odb-12-2-multilingual-4394909-ptb.html
  • 11. Copyright © 2016 Accenture All rights reserved. | 11 https://livesql.oracle.com
  • 12. Copyright © 2016 Accenture All rights reserved. | 12
  • 13. Copyright © 2016 Accenture All rights reserved. | 13 OVERVIEW Database Tuning Vs SQL Tuning
  • 14. Copyright © 2016 Accenture All rights reserved. | 14 OVERVIEW Developers vs SQL
  • 15. Copyright © 2016 Accenture All rights reserved. | 15 TOM KYTE
  • 16. Copyright © 2016 Accenture All rights reserved. | 16 SQL TUNING 101 Let’s begin….
  • 17. Copyright © 2016 Accenture All rights reserved. | 17 SQL TUNING 101 The application is running slow today! Nothing has changed!
  • 18. Copyright © 2016 Accenture All rights reserved. | 18 YES, SOMETHING HAS CHANGED • Database upgraded • Statistics gathered (automatic?) • Schema changed • Database parameter changed • Application changed • Operating system (OS) and hardware changed • Data volume changed • More active users
  • 19. Copyright © 2016 Accenture All rights reserved. | 19 HOW TO START TROUBLESHOOTING? One SQL? All the database? ASH and AWR **Requires Oracle Diagnostics Pack
  • 20. Copyright © 2016 Accenture All rights reserved. | 20 SQL TUNING Proactive
  • 21. Copyright © 2016 Accenture All rights reserved. | 21 SQL TUNING Reactive
  • 22. Copyright © 2016 Accenture All rights reserved. | 22 PROACTIVE – TOOLS
  • 23. Copyright © 2016 Accenture All rights reserved. | 23 EDB360 - TOP SQLS
  • 24. Copyright © 2016 Accenture All rights reserved. | 24 EDB360 - TOP EVENTS
  • 25. Copyright © 2016 Accenture All rights reserved. | 25 EDB360 DEMO
  • 26. Copyright © 2016 Accenture All rights reserved. | 26 AWR REPORT • SQL ordered by Elapsed Time • SQL ordered by CPU Time • SQL ordered by User I/O Wait Time • SQL ordered by Gets • SQL ordered by Reads • SQL ordered by Physical Reads (UnOptimized) • SQL ordered by Executions • SQL ordered by Parse Calls • SQL ordered by Sharable Memory • SQL ordered by Version Count • SQL ordered by Cluster Wait Time
  • 27. Copyright © 2016 Accenture All rights reserved. | 27 AWR REPORT DEMO
  • 28. Copyright © 2016 Accenture All rights reserved. | 28 REACTIVE - TOOLS
  • 29. Copyright © 2016 Accenture All rights reserved. | 29 SQLT (SQLTXPLAIN) DIAGNOSTIC TOOL (DOC ID 215187.1) • Pros: Supported by Oracle • Cons: Requires Installation
  • 30. Copyright © 2016 Accenture All rights reserved. | 30 SQLT (SQLTXPLAIN) DIAGNOSTIC TOOL (DOC ID 215187.1)
  • 31. Copyright © 2016 Accenture All rights reserved. | 31 SQLD360 • Pros: No Installation • Cons: Might miss some information under rare circumstances
  • 32. Copyright © 2016 Accenture All rights reserved. | 32 SQLTXPLAIN VS SQLD360 https://mauro-pagano.com/2017/04/29/sqltxplain-vs-sqld360-differences-and-similarities/
  • 33. Copyright © 2016 Accenture All rights reserved. | 33 SQLD360 – HOW TO USE • Download the free tool: https://github.com/mauropagano/sqld360/ • Execution: SQL> sqld360.sql <sql_id> [N|D|T]
  • 34. Copyright © 2016 Accenture All rights reserved. | 34 SQLD360
  • 35. Copyright © 2016 Accenture All rights reserved. | 35 SQLD360
  • 36. Copyright © 2016 Accenture All rights reserved. | 36 SQLD360
  • 37. Copyright © 2016 Accenture All rights reserved. | 37 SQLD360
  • 38. Copyright © 2016 Accenture All rights reserved. | 38 SQLD360 DEMO
  • 39. Copyright © 2016 Accenture All rights reserved. | 39 SQLD360 If you want to know more: https://mauro-pagano.com/category/sqld360/
  • 40. Copyright © 2016 Accenture All rights reserved. | 40 EXPLAIN PLAN How about Explain Plan?
  • 41. Copyright © 2016 Accenture All rights reserved. | 41 EXPLAIN PLAN Explain Plain lies!
  • 42. Copyright © 2016 Accenture All rights reserved. | 42 EXPLAIN PLAN It does not actually execute the SQL statement. Runtime factors can influence choice of plan: • Dynamic Sampling • Bind Variable Peeking • Adaptive Features
  • 43. Copyright © 2016 Accenture All rights reserved. | 43 NOW WHAT? • DBMS_XPLAN.DISPLAY_CURSOR • V$SQL_PLAN%
  • 44. Copyright © 2016 Accenture All rights reserved. | 44 DBMS_XPLAN.DISPLAY_CURSOR • SQL_ID • CURSOR_CHILD_NO (default 0) • FORMAT TYPICAL = DEFAULT ALL = TYPICAL + QB + PROJECTION + ALIAS + REMOTE ADVANCED = ALL + OUTLINE + BINDS ALLSTATS = IOSTATS + MEMSTATS (all executions) ALLSTATS LAST (last execution) ADAPTIVE (12c)
  • 45. Copyright © 2016 Accenture All rights reserved. | DBMS_XPLAN
  • 46. Copyright © 2016 Accenture All rights reserved. | DBMS_XPLAN Display plan for the last SQL executed: select * from table(dbms_xplan.display_cursor());
  • 47. Copyright © 2016 Accenture All rights reserved. | DBMS_XPLAN Display plan for one specific SQL • Get SQL_ID:
  • 48. Copyright © 2016 Accenture All rights reserved. | SQL_ID - 18C
  • 49. Copyright © 2016 Accenture All rights reserved. | DBMS_XPLAN
  • 50. Copyright © 2016 Accenture All rights reserved. | 50 DBMS_XPLAN DEMO
  • 51. Copyright © 2016 Accenture All rights reserved. | DBMS_XPLAN Child Number ?
  • 52. Copyright © 2016 Accenture All rights reserved. | 52 DBMS_XPLAN DEMO
  • 53. Copyright © 2016 Accenture All rights reserved. |https://blogs.oracle.com/optimizer/entry/how_do_i_know_if /*+ gather_plan_statistics */ or Alter session set statistics_level = ALL ESTIMATE VS ACTUAL
  • 54. Copyright © 2016 Accenture All rights reserved. | 54 ESTIMATE VS ACTUAL DEMO
  • 55. Copyright © 2016 Accenture All rights reserved. | SQL MONITOR • Introduced in Oracle Database 11g. • Automatically started when a SQL statement either runs in parallel or has consumed at least 5 seconds of combined CPU and I/O. • Hint /*+ MONITOR */
  • 56. Copyright © 2016 Accenture All rights reserved. | SQL MONITOR • Oracle Enterprise Manager • EM Database Express (12c) • SQL Developer • Command Line **Part of the Oracle Tuning Pack
  • 57. Copyright © 2016 Accenture All rights reserved. | SQL MONITOR select dbms_sqltune.report_sql_monitor( sql_id => 'gjabwvvr07w09', report_level=>'ALL', type => 'ACTIVE') from dual;
  • 58. Copyright © 2016 Accenture All rights reserved. | SQL MONITOR
  • 59. Copyright © 2016 Accenture All rights reserved. | SQL MONITOR
  • 60. Copyright © 2016 Accenture All rights reserved. | 60 DEMO SQL MONITOR
  • 61. Copyright © 2016 Accenture All rights reserved. | 61 COST OF AN INDEX
  • 62. Copyright © 2016 Accenture All rights reserved. | FULL TABLE SCAN https://www.slideshare.net/MauroPagano3/full-table-scan-friend-or-foe
  • 63. Copyright © 2016 Accenture All rights reserved. | FULL TABLE SCAN https://www.slideshare.net/MauroPagano3/full-table-scan-friend-or-foe
  • 64. Copyright © 2016 Accenture All rights reserved. | FULL TABLE SCAN https://richardfoote.wordpress.com/2008/05/12/index-scan-or-full-table-scan-the-magic-number-magic-dance/
  • 65. Copyright © 2016 Accenture All rights reserved. | FULL TABLE SCAN • Clustering Factor --> How well ordered the rows in the table are in relation to the index. • Selectivity of the query • Number of table blocks • Effective multiblock read count • Relative cost of single vs. multiblock I/Os • Parallelism • Etc
  • 66. Copyright © 2016 Accenture All rights reserved. | FULL TABLE SCAN https://www.slideshare.net/MauroPagano3/full-table-scan-friend-or-foe
  • 67. Copyright © 2016 Accenture All rights reserved. | 67 • Not always good • Not always bad FULL TABLE SCAN
  • 68. Copyright © 2016 Accenture All rights reserved. | 68 ANALYZING TABLES
  • 69. Copyright © 2016 Accenture All rights reserved. | 69 ANALYZING TABLES https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_4005.htm
  • 70. Copyright © 2016 Accenture All rights reserved. | 70 ROW-BY-ROW PROCESSING https://blog.jooq.org/2018/04/19/the-performance-difference-between-sql-row-by-row-updating-batch-updating-and-bulk-updating/
  • 71. Copyright © 2016 Accenture All rights reserved. | 71 ROW-BY-ROW
  • 72. Copyright © 2016 Accenture All rights reserved. | 72 ROW-BY-ROW
  • 73. Copyright © 2016 Accenture All rights reserved. | 73 PL/SQL FORALL
  • 74. Copyright © 2016 Accenture All rights reserved. | 74 ONE UPDATE
  • 75. Copyright © 2016 Accenture All rights reserved. | EVENT 10053
  • 76. Copyright © 2016 Accenture All rights reserved. | EVENT 10053 ALTER SESSION SET EVENTS '10053 trace name context forever, level 1'; SELECT * FROM EMP WHERE ENAME = 'SCOTT'; ALTER SESSION SET EVENTS '10053 trace name context off';
  • 77. Copyright © 2016 Accenture All rights reserved. | EVENT 10053 Level 1 or Level 2? 1. Parameters used by the optimizer (level 1 only) 2. Index statistics (level 1 only) 3. Column statistics 4. Single Access Paths 5. Join Costs 6. Table Joins Considered 7. Join Methods Considered (NL/MS/HA)
  • 78. Copyright © 2016 Accenture All rights reserved. | EVENT 10053 For another session: SYS.DBMS_SYSTEM.SET_EV (SID,SERIAL ,10053,1) Disable: SYS.DBMS_SYSTEM.SET_EV (SID,SERIAL ,10053,0)
  • 79. Copyright © 2016 Accenture All rights reserved. | EVENT 10053 11G R1 ALTER SESSION SET EVENTS 'trace[rdbms.SQL_Optimizer.*][sql:my_sql_id]'; ALTER SESSION SET EVENTS 'trace[rdbms.SQL_Optimizer.*] off';
  • 80. Copyright © 2016 Accenture All rights reserved. | EVENT 10053 11G R2 – 18c dbms_sqldiag.dump_trace( p_sql_id=>’92c3fw9svc3rc’, p_child_number=>0, p_component=>'Compiler', p_file_id=>’MY_Trace_File'); ** Doesn’t require you to re-execute the statement.
  • 81. Copyright © 2016 Accenture All rights reserved. | EVENT 10053
  • 82. Copyright © 2016 Accenture All rights reserved. | EVENT 10053 ALTER SESSION SET EVENTS '10053 trace name context forever, level 1'; SELECT * FROM tb_master p WHERE EXISTS (SELECT 1 FROM tb_detail f WHERE f.id_master=p.id); ALTER SESSION SET EVENTS '10053 trace name context off';
  • 83. Copyright © 2016 Accenture All rights reserved. | EVENT 10053
  • 84. Copyright © 2016 Accenture All rights reserved. | EVENT 10053
  • 85. Copyright © 2016 Accenture All rights reserved. | EVENT 10053 QUERY BLOCK – 2 parts
  • 86. Copyright © 2016 Accenture All rights reserved. | EVENT 10053 Parallelism - Disabled
  • 87. Copyright © 2016 Accenture All rights reserved. | EVENT 10053 Subtitles
  • 88. Copyright © 2016 Accenture All rights reserved. | EVENT 10053 Database Parameters
  • 89. Copyright © 2016 Accenture All rights reserved. | EVENT 10053 System Statistics
  • 90. Copyright © 2016 Accenture All rights reserved. | EVENT 10053 No statistics for these tables
  • 91. Copyright © 2016 Accenture All rights reserved. | EVENT 10053 Dynamic Sampling
  • 92. Copyright © 2016 Accenture All rights reserved. | EVENT 10053 Full Table Scan – No Index
  • 93. Copyright © 2016 Accenture All rights reserved. | EVENT 10053 Original: Final: Final Query
  • 94. Copyright © 2016 Accenture All rights reserved. | EVENT 10053 Final Plan
  • 95. Copyright © 2016 Accenture All rights reserved. | EVENT 10053 Example 2
  • 96. Copyright © 2016 Accenture All rights reserved. | EVENT 10053 Let’s run this one
  • 97. Copyright © 2016 Accenture All rights reserved. | EVENT 10053 Original: Final:
  • 98. Copyright © 2016 Accenture All rights reserved. | 98 Query Transformations EVENT 10053
  • 99. Copyright © 2016 Accenture All rights reserved. | OR EXPANSION Original: SELECT * FROM emp WHERE job = 'CLERK' OR deptno = 10; Changed: SELECT * FROM emp WHERE job = 'CLERK’ UNION ALL SELECT * FROM emp WHERE deptno = 10 AND job <> 'CLERK';
  • 100. Copyright © 2016 Accenture All rights reserved. | SUBQUERY UNNESTING Original: SELECT * FROM accounts WHERE custno IN (SELECT custno FROM customers); Changed: SELECT accounts.* FROM accounts, customers WHERE accounts.custno = customers.custno;
  • 101. Copyright © 2016 Accenture All rights reserved. | VIEW MERGING Original: CREATE VIEW emp_10 AS SELECT empno, ename, job, sal, comm, deptno FROM emp WHERE deptno = 10; SELECT empno FROM emp_10 WHERE empno > 7800; Changed: SELECT empno FROM emp WHERE deptno = 10 AND empno > 7800;
  • 102. Copyright © 2016 Accenture All rights reserved. | PREDICATE PUSHING Original: CREATE VIEW two_emp_tables AS SELECT empno, ename, job, sal, comm, deptno FROM emp1 UNION SELECT empno, ename, job, sal, comm, deptno FROM emp2; SELECT ename FROM two_emp_tables WHERE deptno = 20;
  • 103. Copyright © 2016 Accenture All rights reserved. | PREDICATE PUSHING Changed: SELECT ename FROM ( SELECT empno, ename, job,sal, comm, deptno FROM emp1 WHERE deptno = 20 UNION SELECT empno, ename, job,sal, comm, deptno FROM emp2 WHERE deptno = 20 );
  • 104. Copyright © 2016 Accenture All rights reserved. | TRANSITIVITY Original: SELECT * FROM emp, dept WHERE emp.deptno = 20 AND emp.deptno = dept.deptno; Changed: SELECT * FROM emp, dept WHERE emp.deptno = 20 AND emp.deptno = dept.deptno AND dept.deptno = 20;
  • 105. Copyright © 2016 Accenture All rights reserved. | 105 COUNT(1) VS COUNT(*) What is the difference between count(1) and count(*) ?
  • 106. Copyright © 2016 Accenture All rights reserved. | 106 COUNT(1) VS COUNT(*) Nothing
  • 107. Copyright © 2016 Accenture All rights reserved. | 107 COUNT(1) VS COUNT(*)
  • 108. Copyright © 2016 Accenture All rights reserved. | MORE ABOUT THE EVENT 10053
  • 109. Copyright © 2016 Accenture All rights reserved. |
  • 110. Copyright © 2016 Accenture All rights reserved. | Oracle Database 12.1 OPTIMIZER_ADAPTIVE_FEATURES Default TRUE ADAPTIVE FEATURES
  • 111. Copyright © 2016 Accenture All rights reserved. | Oracle Database 12.2 introduces the new split- up adaptive parameters: • OPTIMIZER_ADAPTIVE_PLANS • OPTIMITER_ADAPTIVE_STATISTICS ADAPTIVE FEATURES
  • 112. Copyright © 2016 Accenture All rights reserved. | On Oracle Database 12.1 this can be achieved by installing two patches. ADAPTIVE FEATURES
  • 113. Copyright © 2016 Accenture All rights reserved. | The patch for bug# 22652097 introduces the two parameters OPTIMIZER_ADAPTIVE_PLANS and OPTIMIZER_ADAPTIVE_STATISTICS, and in addition removes the parameter OPTIMIZER_ADAPTIVE_FEATURES. The patch for bug# 21171382 disables the automatic creation of extended statistics unless the optimizer preference AUTO_STATS_EXTENSIONS is set to ON. ADAPTIVE FEATURES
  • 114. Copyright © 2016 Accenture All rights reserved. | https://blogs.oracle.com/optimizer/entry/improvement_of_auto_sampling_statistics_gathering_feature_in_oracle_database_11g estimate_percent => dbms_stats.auto_sample_size STATISTICS
  • 115. Copyright © 2016 Accenture All rights reserved. | Should I use? HINTS
  • 116. Copyright © 2016 Accenture All rights reserved. | Query running on M7: 180 Minutes Query after db clone  P8+Storage ? • Time: 29 hours Query running on M7 after SQL tuning: 17 minutes SQL TUNING ON EXADATA
  • 117. Copyright © 2016 Accenture All rights reserved. | SQL TUNING ON EXADATA
  • 118. Copyright © 2016 Accenture All rights reserved. |
  • 119. Copyright © 2016 Accenture All rights reserved. | Set table preferences: begin dbms_stats.set_table_prefs ( ownname => 'SCOTT', tabname => 'EMP', pname => 'PUBLISH', pvalue => 'FALSE' ); end; Collect the statistics. PENDING STATISTICS
  • 120. Copyright © 2016 Accenture All rights reserved. | select num_rows, to_char(last_analyzed,'dd/mm/rrrr hh24:mi:ss’) from all_tab_pending_stats where table_name = 'EMP'; PENDING STATISTICS
  • 121. Copyright © 2016 Accenture All rights reserved. | alter session set optimizer_use_pending_statistics = true; Test your queries. PENDING STATISTICS
  • 122. Copyright © 2016 Accenture All rights reserved. | If it’s ok: dbms_stats.publish_pending_stats('SCOTT', 'EMP’); or: dbms_stats.delete_pending_stats(’SCOTT',’EMP'); PENDING STATISTICS
  • 123. Copyright © 2016 Accenture All rights reserved. | Check the retention: select DBMS_STATS.GET_STATS_HISTORY_RETENTION from dual; Default is 31 days. RESTORE STATISTICS FROM HISTORY
  • 124. Copyright © 2016 Accenture All rights reserved. | Statistics available for the table: SELECT OWNER, TABLE_NAME, STATS_UPDATE_TIME FROM dba_tab_stats_history WHERE table_name='MY_TABLE'; RESTORE STATISTICS FROM HISTORY
  • 125. Copyright © 2016 Accenture All rights reserved. | Begin dbms_stats.restore_table_stats( 'SCOTT', 'EMP', ‘08-NOV-16 11.38.05.015640 AM +08:00’); End; RESTORE STATISTICS FROM HISTORY
  • 126. Copyright © 2016 Accenture All rights reserved. | begin dbms_stats.CREATE_STAT_TABLE( ownname=>user , stattab=>'MY_STATS_TABLE' ); end; begin dbms_stats.export_schema_stats( ownname=>user , stattab=>'MY_STATS_TABLE' , statid=>'CURRENT_STATS' ); end; EXPORT AND IMPORT SCHEMA STATISTICS
  • 127. Copyright © 2016 Accenture All rights reserved. | EXPDP / IMPDP begin dbms_stats.import_schema_stats( ownname=>user , stattab=>'MY_STATS_TABLE' , statid=>'CURRENT_STATS' ); End; EXPORT AND IMPORT SCHEMA STATISTICS
  • 128. Copyright © 2016 Accenture All rights reserved. | Incremental statistics for partitioned tables: dbms_stats.set_table_prefs(null,'SALES','INCREMENTAL','TRUE') INCREMENTAL STATISTICS
  • 129. Copyright © 2016 Accenture All rights reserved. | INCREMENTAL STATISTICS
  • 130. Copyright © 2016 Accenture All rights reserved. | CREATE INDEX index_name ON table_name(column_name) INVISIBLE; ALTER INDEX index_name INVISIBLE; ALTER INDEX index_name VISIBLE; INVISIBLE INDEXES
  • 131. Copyright © 2016 Accenture All rights reserved. | ALTER SESSION SET OPTIMIZER_USE_INVISIBLE_INDEXES=TRUE; INVISIBLE INDEXES
  • 132. Copyright © 2016 Accenture All rights reserved. | ALTER SESSION SET sql_trace=TRUE; ALTER SESSION SET sql_trace=FALSE; EXEC DBMS_SESSION.set_sql_trace(sql_trace => TRUE); EXEC DBMS_SESSION.set_sql_trace(sql_trace => FALSE); ALTER SESSION SET EVENTS '10046 trace name context forever, level 12'; ALTER SESSION SET EVENTS '10046 trace name context off'; EXEC DBMS_SYSTEM.set_sql_trace_in_session(sid=>0000, serial#=>0000, sql_trace=>TRUE); EXEC DBMS_SYSTEM.set_sql_trace_in_session(sid=>0000, serial#=>0000, sql_trace=>FALSE); SQL TRACE, 10046, TRCSESS AND TKPROF
  • 133. Copyright © 2016 Accenture All rights reserved. | CONN sys/password AS SYSDBA; ORADEBUG SETMYPID; ORADEBUG SETOSPID 0000; ORADEBUG SETORAPID 000000; ORADEBUG EVENT 10046 TRACE NAME CONTEXT FOREVER, LEVEL 12; ORADEBUG EVENT 10046 TRACE NAME CONTEXT OFF; SQL TRACE, 10046, TRCSESS AND TKPROF
  • 134. Copyright © 2016 Accenture All rights reserved. | EXEC DBMS_SUPPORT.start_trace(waits=>TRUE, binds=>TRUE); EXEC DBMS_SUPPORT.stop_trace; EXEC DBMS_SUPPORT.start_trace_in_session(sid=>0000, serial=>000000, waits=>TRUE, binds=>TRUE); EXEC DBMS_SUPPORT.stop_trace_in_session(sid=>0000, serial=>000000); SQL TRACE, 10046, TRCSESS AND TKPROF
  • 135. Copyright © 2016 Accenture All rights reserved. | 10g: DBMS_MONITOR.session_trace_enable(waits=>TRUE, binds=>FALSE); DBMS_MONITOR.session_trace_enable(session_id =>0000, serial_num=>000000, waits=>TRUE, binds=>TRUE); DBMS_MONITOR.client_id_trace_enable(client_id=>'my_client', waits=>TRUE, binds=>TRUE); DBMS_MONITOR.serv_mod_act_trace_enable(service_name=>'my_srv', module_name=>'my_test', action_name=>'calculating', waits=>TRUE, binds=>TRUE); SQL TRACE, 10046, TRCSESS AND TKPROF
  • 136. Copyright © 2016 Accenture All rights reserved. | ALTER SESSION SET TRACEFILE_IDENTIFIER = "MY_TRC_FILE"; SQL TRACE, 10046, TRCSESS AND TKPROF
  • 137. Copyright © 2016 Accenture All rights reserved. | SELECT p.tracefile FROM v$session s JOIN v$process p ON s.paddr = p.addr WHERE s.sid = MY_SID; SQL TRACE, 10046, TRCSESS AND TKPROF
  • 138. Copyright © 2016 Accenture All rights reserved. | 12.2 v$diag_trace_file v$diag_trace_file_contents SQL TRACE, 10046, TRCSESS AND TKPROF
  • 139. Copyright © 2016 Accenture All rights reserved. | EVENT 10046
  • 140. Copyright © 2016 Accenture All rights reserved. | ALTER SESSION SET EVENTS '10046 trace name context forever, level 12'; SELECT * FROM tb_pai p WHERE EXISTS (SELECT 1 FROM tb_filho f WHERE f.id_pai=p.id); ALTER SESSION SET EVENTS '10046 trace name context off'; EVENT 10046
  • 141. Copyright © 2016 Accenture All rights reserved. | EVENT 10046
  • 142. Copyright © 2016 Accenture All rights reserved. | EVENT 10046
  • 143. Copyright © 2016 Accenture All rights reserved. | EVENT 10046
  • 144. Copyright © 2016 Accenture All rights reserved. | EVENT 10046
  • 145. Copyright © 2016 Accenture All rights reserved. | EVENT 10046
  • 146. Copyright © 2016 Accenture All rights reserved. | EVENT 10046
  • 147. Copyright © 2016 Accenture All rights reserved. | • TKPROF • TRCSESS • Trace Analyzer TRCANLZR (TRCA) • Method R Tools SQL TRACE, 10046, TRCSESS AND TKPROF
  • 148. Copyright © 2016 Accenture All rights reserved. | SQL TRACE, 10046, TRCSESS AND TKPROF
  • 149. Copyright © 2016 Accenture All rights reserved. |http://www.oraclenerd.com/2011/02/sql-developer-mr-trace.html SQL TRACE, 10046, TRCSESS AND TKPROF
  • 150. Copyright © 2016 Accenture All rights reserved. | 150 SQLCL http://www.oracle.com/technetwork/developer-tools/sqlcl/downloads/index.html
  • 151. Copyright © 2016 Accenture All rights reserved. | 151 QUESTIONS?
  • 152. Copyright © 2016 Accenture All rights reserved. | 152 Thank You Slides Available: http://www.slideshare.net/

Notas del editor

  1. SQL TUNING – more effective
  2. New Developers are not happy learning SQL SQL still the best way to manipulate DATA, including BIG DATA - Spark SQL - Cloudera Impala - Oracle Big Data SQL - Apache Hive
  3. Not common We have more than 100 databases to administer
  4. Free tool edb360 By Carlos Sierra
  5. AWR History Default – 8 days
  6. Período específico
  7. No installation Free
  8. FKs - enq: TM – contention  In-Memory – speed OLTP
  9. Muitos Dbas acham q tuning é remover FTS
  10. Mito %
  11. let’s go deeper…