SlideShare una empresa de Scribd logo
1 de 18
Performance Tuning: How to write correctly
Ronald Vargas Quesada, Oracle ACE
Expertise Database Management & Performance
Technical PreSales Consultant, Netsoft de Centroamérica
For Oracle employees and authorized partners only. Do not distribute to third parties.
© 2012 Oracle Corporation – Proprietary and Confidential

1
Performance Tuning: How to write correctly
<function> ( <arg>,<arg>,..)
OVER (
<partition clause>
<sorting clause>
<windowing clause>
)
For Oracle employees and authorized partners only. Do not distribute to third parties.
© 2012 Oracle Corporation – Proprietary and Confidential

2
Performance Tuning: How to write correctly
<function> ( <arg>,<arg>,..)
OVER | KEEP | WITHING GROUP (
<partition clause>
<sorting clause>
<windowing clause>
)
For Oracle employees and authorized partners only. Do not distribute to third parties.
© 2012 Oracle Corporation – Proprietary and Confidential

3
Performance Tuning: How to write correctly

That´s it !
That´s it friends!

For Oracle employees and authorized partners only. Do not distribute to third parties.
© 2012 Oracle Corporation – Proprietary and Confidential

4
Performance Tuning: How to write correctly

quick example #1

For Oracle employees and authorized partners only. Do not distribute to third parties.
© 2012 Oracle Corporation – Proprietary and Confidential

5
employees by salary

For Oracle employees and authorized partners only. Do not distribute to third parties.
© 2012 Oracle Corporation – Proprietary and Confidential

6
Performance Tuning: How to write correctly
SQL> select employee_id, job_id, hire_date, salary
2 from employees
3 order by salary;
EMPLOYEE_ID
----------132
136
128
127
135
191
119
140
144
182
131

JOB_ID
---------ST_CLERK
ST_CLERK
ST_CLERK
ST_CLERK
ST_CLERK
SH_CLERK
PU_CLERK
ST_CLERK
ST_CLERK
SH_CLERK
ST_CLERK

HIRE_DATE
SALARY
--------- ---------10-APR-07
2100
06-FEB-08
2200
08-MAR-08
2200
14-JAN-07
2400
12-DEC-07
2400
19-DEC-07
2500
10-AUG-07
2500
06-APR-06
2500
09-JUL-06
2500
21-JUN-07
2500
16-FEB-05
2500

For Oracle employees and authorized partners only. Do not distribute to third parties.
© 2012 Oracle Corporation – Proprietary and Confidential

7
Performance Tuning: How to write correctly

Who hired first ?
hiring sequence

For Oracle employees and authorized partners only. Do not distribute to third parties.
© 2012 Oracle Corporation – Proprietary and Confidential

8
Performance Tuning: How to write correctly
1

2
3
4
5
6
7
8*
SQL>

select e.employee_id, e.first_name, e.job_id, e.hire_date, e.salary, x.sequence
from employees e,
(select e2.employee_id, count(*) sequence from employees e1, employees e2
where e1.hire_date <= e2.hire_date
group by e2.employee_id
) x
where e.employee_id = x.employee_id
order by salary
/

EMPLOYEE_ID
----------132
128
136
135
127
144

very
complicated !!

FIRST_NAME
-------------------TJ
Steven
Hazel
Ki
James
Peter

JOB_ID
---------ST_CLERK
ST_CLERK
ST_CLERK
ST_CLERK
ST_CLERK
ST_CLERK

HIRE_DATE
SALARY
SEQUENCE
--------- ---------- ---------10-APR-07
2100
85
08-MAR-08
2200
104
06-FEB-08
2200
102
12-DEC-07
2400
95
14-JAN-07
2400
78
09-JUL-06
2500
71

For Oracle employees and authorized partners only. Do not distribute to third parties.
© 2012 Oracle Corporation – Proprietary and Confidential

9
Performance Tuning: How to write correctly

Is very simple ?

For Oracle employees and authorized partners only. Do not distribute to third parties.
© 2012 Oracle Corporation – Proprietary and Confidential

10
Performance Tuning: How to write correctly

Much or little work ?

For Oracle employees and authorized partners only. Do not distribute to third parties.
© 2012 Oracle Corporation – Proprietary and Confidential

11
Performance Tuning: How to write correctly
PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------Plan hash value: 2074273239
------------------------------------------------------------------------------------| Id | Operation
| Name
| Rows | Bytes | Cost (%CPU)| Time
|
------------------------------------------------------------------------------------|
0 | SELECT STATEMENT
|
|
107 | 5243 |
14 (36)| 00:00:01 |
|
1 | SORT ORDER BY
|
|
107 | 5243 |
14 (36)| 00:00:01 |
|* 2 |
HASH JOIN
|
|
107 | 5243 |
13 (31)| 00:00:01 |
|
3 |
TABLE ACCESS FULL
| EMPLOYEES |
107 | 3424 |
3
(0)| 00:00:01 |
|
4 |
VIEW
|
|
107 | 1819 |
9 (34)| 00:00:01 |
|
5 |
HASH GROUP BY
|
|
107 | 2140 |
9 (34)| 00:00:01 |
|
6 |
MERGE JOIN
|
| 5783 |
112K|
8 (25)| 00:00:01 |
|
7 |
SORT JOIN
|
|
107 |
856 |
4 (25)| 00:00:01 |
|
8 |
TABLE ACCESS FULL| EMPLOYEES |
107 |
856 |
3
(0)| 00:00:01 |
|* 9 |
SORT JOIN
|
|
107 | 1284 |
4 (25)| 00:00:01 |
| 10 |
TABLE ACCESS FULL| EMPLOYEES |
107 | 1284 |
3
(0)| 00:00:01 |
------------------------------------------------------------------------------------Predicate Information (identified by operation id):
--------------------------------------------------2 - access("E"."EMPLOYEE_ID"="X"."EMPLOYEE_ID")
9 - access("E1"."HIRE_DATE"<="E2"."HIRE_DATE")
filter("E1"."HIRE_DATE"<="E2"."HIRE_DATE") 24 rows selected.

For Oracle employees and authorized partners only. Do not distribute to third parties.
© 2012 Oracle Corporation – Proprietary and Confidential

12
Performance Tuning: How to write correctly

Make it Simple !!

For Oracle employees and authorized partners only. Do not distribute to third parties.
© 2012 Oracle Corporation – Proprietary and Confidential

13
Performance Tuning: How to write correctly
SQL> select employee_id, first_name, job_id, hire_date, salary, rank() over (order by
hire_date) as hire_seq
2 from employees
3 order by salary;

EMPLOYEE_ID
----------132
136
128
127
135
131
140
144

FIRST_NAME
-------------------TJ
Hazel
Steven
James
Ki
James
Joshua
Peter

JOB_ID
---------ST_CLERK
ST_CLERK
ST_CLERK
ST_CLERK
ST_CLERK
ST_CLERK
ST_CLERK
ST_CLERK

HIRE_DATE
SALARY
HIRE_SEQ
--------- ---------- ---------10-APR-07
2100
85
06-FEB-08
2200
102
08-MAR-08
2200
104
14-JAN-07
2400
78
12-DEC-07
2400
95
16-FEB-05
2500
28
06-APR-06
2500
65
09-JUL-06
2500
71

For Oracle employees and authorized partners only. Do not distribute to third parties.
© 2012 Oracle Corporation – Proprietary and Confidential

14
Performance Tuning: How to write correctly
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------Plan hash value: 1701542182
--------------------------------------------------------------------------------| Id | Operation
| Name
| Rows | Bytes | Cost (%CPU)| Time
|
--------------------------------------------------------------------------------|
0 | SELECT STATEMENT
|
|
107 | 3424 |
5 (40)| 00:00:01 |
|
1 | SORT ORDER BY
|
|
107 | 3424 |
5 (40)| 00:00:01 |
|
2 |
WINDOW SORT
|
|
107 | 3424 |
5 (40)| 00:00:01 |
|
3 |
TABLE ACCESS FULL| EMPLOYEES |
107 | 3424 |
3
(0)| 00:00:01 |
--------------------------------------------------------------------------------10 rows selected.

For Oracle employees and authorized partners only. Do not distribute to third parties.
© 2012 Oracle Corporation – Proprietary and Confidential

15
Performance Tuning: How to write correctly
Not using bind variable
SQL> host
[oracle@LAB1 ~]$ vi script1.sql
[oracle@LAB1 ~]$ more script1.sql
set timing on
begin
for i in 1 .. 100000
loop
execute immediate
'insert into t (x,y)
values ( ' || i || ', ''x'') ';
end loop;
end;
/
[oracle@LAB1 ~]$

For Oracle employees and authorized partners only. Do not distribute to third parties.
© 2012 Oracle Corporation – Proprietary and Confidential

16
Performance Tuning: How to write correctly
Using Bind variable
[oracle@LAB1 ~]$ more script2.sql
set timing on
begin
for i in 1 .. 100000
loop
execute immediate
'insert into t (x,y)
values ( :i, ''x'')'
using i;
end loop;
end;
/
[oracle@LAB1 ~]$

For Oracle employees and authorized partners only. Do not distribute to third parties.
© 2012 Oracle Corporation – Proprietary and Confidential

17
@rovaque
oracledbacr.blogspot.com
ronald.vargas.quesada@gmail.com

For Oracle employees and authorized partners only. Do not distribute to third parties.
© 2012 Oracle Corporation – Proprietary and Confidential

18

Más contenido relacionado

La actualidad más candente

1 z0 062 - oracle certification
1 z0 062 - oracle certification1 z0 062 - oracle certification
1 z0 062 - oracle certificationadam_jhon
 
Oracle performance management_implementation_and_user_guide
Oracle performance management_implementation_and_user_guideOracle performance management_implementation_and_user_guide
Oracle performance management_implementation_and_user_guidegisdev1
 
1Z0-050 - Oracle Database
1Z0-050 - Oracle Database1Z0-050 - Oracle Database
1Z0-050 - Oracle Databaseadam_jhon
 
Oracle Succession Planning Setup
Oracle Succession Planning SetupOracle Succession Planning Setup
Oracle Succession Planning SetupFeras Ahmad
 
Optimizing the Enterprise Manager 12c
Optimizing the Enterprise Manager 12cOptimizing the Enterprise Manager 12c
Optimizing the Enterprise Manager 12cKellyn Pot'Vin-Gorman
 
121perfmiug
121perfmiug121perfmiug
121perfmiugrpkapps
 
SAP HANA in an EMC Private Cloud
SAP HANA in an EMC Private CloudSAP HANA in an EMC Private Cloud
SAP HANA in an EMC Private CloudEMC
 
Oracle Database features every developer should know about
Oracle Database features every developer should know aboutOracle Database features every developer should know about
Oracle Database features every developer should know aboutgvenzl
 

La actualidad más candente (9)

1 z0 062 - oracle certification
1 z0 062 - oracle certification1 z0 062 - oracle certification
1 z0 062 - oracle certification
 
UKOUG
UKOUG UKOUG
UKOUG
 
Oracle performance management_implementation_and_user_guide
Oracle performance management_implementation_and_user_guideOracle performance management_implementation_and_user_guide
Oracle performance management_implementation_and_user_guide
 
1Z0-050 - Oracle Database
1Z0-050 - Oracle Database1Z0-050 - Oracle Database
1Z0-050 - Oracle Database
 
Oracle Succession Planning Setup
Oracle Succession Planning SetupOracle Succession Planning Setup
Oracle Succession Planning Setup
 
Optimizing the Enterprise Manager 12c
Optimizing the Enterprise Manager 12cOptimizing the Enterprise Manager 12c
Optimizing the Enterprise Manager 12c
 
121perfmiug
121perfmiug121perfmiug
121perfmiug
 
SAP HANA in an EMC Private Cloud
SAP HANA in an EMC Private CloudSAP HANA in an EMC Private Cloud
SAP HANA in an EMC Private Cloud
 
Oracle Database features every developer should know about
Oracle Database features every developer should know aboutOracle Database features every developer should know about
Oracle Database features every developer should know about
 

Similar a Performance tuning how to write correctly sql statement

Performance Tuning: Como escribir y correr correctamente una sentencia SQL en...
Performance Tuning: Como escribir y correr correctamente una sentencia SQL en...Performance Tuning: Como escribir y correr correctamente una sentencia SQL en...
Performance Tuning: Como escribir y correr correctamente una sentencia SQL en...Ronald Francisco Vargas Quesada
 
Oracle Database 12c Application Development
Oracle Database 12c Application DevelopmentOracle Database 12c Application Development
Oracle Database 12c Application DevelopmentSaurabh K. Gupta
 
More than 12 More things about Oracle Database 12c
More than 12 More things about Oracle Database 12cMore than 12 More things about Oracle Database 12c
More than 12 More things about Oracle Database 12cGuatemala User Group
 
Latin America Tour 2019 - pattern matching
Latin America Tour 2019 - pattern matchingLatin America Tour 2019 - pattern matching
Latin America Tour 2019 - pattern matchingConnor McDonald
 
Five more things about Oracle SQL and PLSQL
Five more things about Oracle SQL and PLSQLFive more things about Oracle SQL and PLSQL
Five more things about Oracle SQL and PLSQLConnor McDonald
 
MERGE SQL Statement: Lesser Known Facets
MERGE SQL Statement: Lesser Known FacetsMERGE SQL Statement: Lesser Known Facets
MERGE SQL Statement: Lesser Known FacetsAndrej Pashchenko
 
New PLSQL in Oracle Database 12c
New PLSQL in Oracle Database 12cNew PLSQL in Oracle Database 12c
New PLSQL in Oracle Database 12cConnor McDonald
 
Pattern Matching with SQL - APEX World Rotterdam 2019
Pattern Matching with SQL - APEX World Rotterdam 2019Pattern Matching with SQL - APEX World Rotterdam 2019
Pattern Matching with SQL - APEX World Rotterdam 2019Connor McDonald
 
Analytic functions in Oracle SQL - BIWA 2017
Analytic functions in Oracle SQL - BIWA 2017Analytic functions in Oracle SQL - BIWA 2017
Analytic functions in Oracle SQL - BIWA 2017Connor McDonald
 
Database Management System
Database Management SystemDatabase Management System
Database Management SystemHitesh Mohapatra
 
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكل
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكلحل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكل
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكلMohamed Moustafa
 
Performance tuning a quick intoduction
Performance tuning   a quick intoductionPerformance tuning   a quick intoduction
Performance tuning a quick intoductionRiyaj Shamsudeen
 
DB 3 Sybase ASE 15 & MS SQL Server
DB 3 Sybase ASE 15 & MS SQL Server DB 3 Sybase ASE 15 & MS SQL Server
DB 3 Sybase ASE 15 & MS SQL Server Sunny U Okoro
 
Lesson05 从多表中查询数据
Lesson05 从多表中查询数据Lesson05 从多表中查询数据
Lesson05 从多表中查询数据renguzi
 
SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?Andrej Pashchenko
 
Restricting and sorting data
Restricting and sorting data Restricting and sorting data
Restricting and sorting data HuzaifaMushtaq3
 

Similar a Performance tuning how to write correctly sql statement (20)

Performance Tuning: Como escribir y correr correctamente una sentencia SQL en...
Performance Tuning: Como escribir y correr correctamente una sentencia SQL en...Performance Tuning: Como escribir y correr correctamente una sentencia SQL en...
Performance Tuning: Como escribir y correr correctamente una sentencia SQL en...
 
Oracle Database 12c Application Development
Oracle Database 12c Application DevelopmentOracle Database 12c Application Development
Oracle Database 12c Application Development
 
More than 12 More things about Oracle Database 12c
More than 12 More things about Oracle Database 12cMore than 12 More things about Oracle Database 12c
More than 12 More things about Oracle Database 12c
 
Latin America Tour 2019 - pattern matching
Latin America Tour 2019 - pattern matchingLatin America Tour 2019 - pattern matching
Latin America Tour 2019 - pattern matching
 
Oracle Advanced SQL
Oracle Advanced SQLOracle Advanced SQL
Oracle Advanced SQL
 
Five more things about Oracle SQL and PLSQL
Five more things about Oracle SQL and PLSQLFive more things about Oracle SQL and PLSQL
Five more things about Oracle SQL and PLSQL
 
MERGE SQL Statement: Lesser Known Facets
MERGE SQL Statement: Lesser Known FacetsMERGE SQL Statement: Lesser Known Facets
MERGE SQL Statement: Lesser Known Facets
 
New PLSQL in Oracle Database 12c
New PLSQL in Oracle Database 12cNew PLSQL in Oracle Database 12c
New PLSQL in Oracle Database 12c
 
Pattern Matching with SQL - APEX World Rotterdam 2019
Pattern Matching with SQL - APEX World Rotterdam 2019Pattern Matching with SQL - APEX World Rotterdam 2019
Pattern Matching with SQL - APEX World Rotterdam 2019
 
Analytic functions in Oracle SQL - BIWA 2017
Analytic functions in Oracle SQL - BIWA 2017Analytic functions in Oracle SQL - BIWA 2017
Analytic functions in Oracle SQL - BIWA 2017
 
Database Management System
Database Management SystemDatabase Management System
Database Management System
 
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكل
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكلحل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكل
حل اسئلة الكتاب السعودى فى شرح قواعد البيانات اوراكل
 
Performance tuning a quick intoduction
Performance tuning   a quick intoductionPerformance tuning   a quick intoduction
Performance tuning a quick intoduction
 
DB 3 Sybase ASE 15 & MS SQL Server
DB 3 Sybase ASE 15 & MS SQL Server DB 3 Sybase ASE 15 & MS SQL Server
DB 3 Sybase ASE 15 & MS SQL Server
 
Oracle SQL Tuning
Oracle SQL TuningOracle SQL Tuning
Oracle SQL Tuning
 
Lesson05 从多表中查询数据
Lesson05 从多表中查询数据Lesson05 从多表中查询数据
Lesson05 从多表中查询数据
 
Sqlplus
SqlplusSqlplus
Sqlplus
 
SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?
 
Restricting and sorting data
Restricting and sorting data Restricting and sorting data
Restricting and sorting data
 
chap2 (3).ppt
chap2 (3).pptchap2 (3).ppt
chap2 (3).ppt
 

Más de Ronald Francisco Vargas Quesada

01 Ronald Vargas 18c cloud service el siguiente paso en la nueva generacion
01 Ronald Vargas 18c cloud service el siguiente paso en la nueva generacion01 Ronald Vargas 18c cloud service el siguiente paso en la nueva generacion
01 Ronald Vargas 18c cloud service el siguiente paso en la nueva generacionRonald Francisco Vargas Quesada
 
01 Ronald Vargas Verdades ciertas, mitos y falacias sobre oracle database 19c
01 Ronald Vargas Verdades ciertas, mitos y falacias sobre oracle database 19c01 Ronald Vargas Verdades ciertas, mitos y falacias sobre oracle database 19c
01 Ronald Vargas Verdades ciertas, mitos y falacias sobre oracle database 19cRonald Francisco Vargas Quesada
 
Ronald vargas big data universidad hispanoamericana v2.1
Ronald vargas big data universidad hispanoamericana  v2.1Ronald vargas big data universidad hispanoamericana  v2.1
Ronald vargas big data universidad hispanoamericana v2.1Ronald Francisco Vargas Quesada
 
Ronald vargas presente y futuro la adolescencia de los super sistemas computa...
Ronald vargas presente y futuro la adolescencia de los super sistemas computa...Ronald vargas presente y futuro la adolescencia de los super sistemas computa...
Ronald vargas presente y futuro la adolescencia de los super sistemas computa...Ronald Francisco Vargas Quesada
 
Ronald Vargas 18c cloud service el siguiente paso en la nueva generacion
Ronald Vargas 18c cloud service el siguiente paso en la nueva generacionRonald Vargas 18c cloud service el siguiente paso en la nueva generacion
Ronald Vargas 18c cloud service el siguiente paso en la nueva generacionRonald Francisco Vargas Quesada
 
Computación Cognitiva: Mejorando la experiencia del Cliente
Computación Cognitiva: Mejorando la experiencia del ClienteComputación Cognitiva: Mejorando la experiencia del Cliente
Computación Cognitiva: Mejorando la experiencia del ClienteRonald Francisco Vargas Quesada
 
Oracle Database 12cR2 Hacking Etico. Viaje a la zona desconocida.
Oracle Database 12cR2 Hacking Etico. Viaje a la zona desconocida.Oracle Database 12cR2 Hacking Etico. Viaje a la zona desconocida.
Oracle Database 12cR2 Hacking Etico. Viaje a la zona desconocida.Ronald Francisco Vargas Quesada
 
Oracle Database 12c Arquitectura Single & Multitenant Español
Oracle Database 12c Arquitectura Single & Multitenant EspañolOracle Database 12c Arquitectura Single & Multitenant Español
Oracle Database 12c Arquitectura Single & Multitenant EspañolRonald Francisco Vargas Quesada
 
Ronald vargas computación cognitiva computación del conocimiento introduccion
Ronald vargas computación cognitiva  computación del conocimiento introduccionRonald vargas computación cognitiva  computación del conocimiento introduccion
Ronald vargas computación cognitiva computación del conocimiento introduccionRonald Francisco Vargas Quesada
 
Ventajas y beneficios de oracle database 12c el manejo de datos en la 3era pl...
Ventajas y beneficios de oracle database 12c el manejo de datos en la 3era pl...Ventajas y beneficios de oracle database 12c el manejo de datos en la 3era pl...
Ventajas y beneficios de oracle database 12c el manejo de datos en la 3era pl...Ronald Francisco Vargas Quesada
 
Charla técnica comercial v3.0 junio 2014 db visit productos
Charla técnica comercial v3.0 junio 2014 db visit productosCharla técnica comercial v3.0 junio 2014 db visit productos
Charla técnica comercial v3.0 junio 2014 db visit productosRonald Francisco Vargas Quesada
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cRonald Francisco Vargas Quesada
 

Más de Ronald Francisco Vargas Quesada (20)

01 Ronald Vargas 18c cloud service el siguiente paso en la nueva generacion
01 Ronald Vargas 18c cloud service el siguiente paso en la nueva generacion01 Ronald Vargas 18c cloud service el siguiente paso en la nueva generacion
01 Ronald Vargas 18c cloud service el siguiente paso en la nueva generacion
 
01 Ronald Vargas Verdades ciertas, mitos y falacias sobre oracle database 19c
01 Ronald Vargas Verdades ciertas, mitos y falacias sobre oracle database 19c01 Ronald Vargas Verdades ciertas, mitos y falacias sobre oracle database 19c
01 Ronald Vargas Verdades ciertas, mitos y falacias sobre oracle database 19c
 
Análisis de Datos: La guerra, la humanidad y el futuro
Análisis de Datos: La guerra, la humanidad y el futuroAnálisis de Datos: La guerra, la humanidad y el futuro
Análisis de Datos: La guerra, la humanidad y el futuro
 
Oracle Database XE 18c
Oracle Database XE 18cOracle Database XE 18c
Oracle Database XE 18c
 
Ronald vargas big data universidad hispanoamericana v2.1
Ronald vargas big data universidad hispanoamericana  v2.1Ronald vargas big data universidad hispanoamericana  v2.1
Ronald vargas big data universidad hispanoamericana v2.1
 
Ronald vargas presente y futuro la adolescencia de los super sistemas computa...
Ronald vargas presente y futuro la adolescencia de los super sistemas computa...Ronald vargas presente y futuro la adolescencia de los super sistemas computa...
Ronald vargas presente y futuro la adolescencia de los super sistemas computa...
 
Ronald Vargas 18c cloud service el siguiente paso en la nueva generacion
Ronald Vargas 18c cloud service el siguiente paso en la nueva generacionRonald Vargas 18c cloud service el siguiente paso en la nueva generacion
Ronald Vargas 18c cloud service el siguiente paso en la nueva generacion
 
Computación Cognitiva: Mejorando la experiencia del Cliente
Computación Cognitiva: Mejorando la experiencia del ClienteComputación Cognitiva: Mejorando la experiencia del Cliente
Computación Cognitiva: Mejorando la experiencia del Cliente
 
Oracle Database 12cR2 Hacking Etico. Viaje a la zona desconocida.
Oracle Database 12cR2 Hacking Etico. Viaje a la zona desconocida.Oracle Database 12cR2 Hacking Etico. Viaje a la zona desconocida.
Oracle Database 12cR2 Hacking Etico. Viaje a la zona desconocida.
 
Oracle Database 12c Arquitectura Single & Multitenant Español
Oracle Database 12c Arquitectura Single & Multitenant EspañolOracle Database 12c Arquitectura Single & Multitenant Español
Oracle Database 12c Arquitectura Single & Multitenant Español
 
Ronald vargas computación cognitiva computación del conocimiento introduccion
Ronald vargas computación cognitiva  computación del conocimiento introduccionRonald vargas computación cognitiva  computación del conocimiento introduccion
Ronald vargas computación cognitiva computación del conocimiento introduccion
 
Oracle Database SE2 Single Tenant 12c
Oracle Database SE2 Single Tenant 12cOracle Database SE2 Single Tenant 12c
Oracle Database SE2 Single Tenant 12c
 
Oracle Database Hacking Etico
Oracle Database Hacking EticoOracle Database Hacking Etico
Oracle Database Hacking Etico
 
Ventajas y beneficios de oracle database 12c el manejo de datos en la 3era pl...
Ventajas y beneficios de oracle database 12c el manejo de datos en la 3era pl...Ventajas y beneficios de oracle database 12c el manejo de datos en la 3era pl...
Ventajas y beneficios de oracle database 12c el manejo de datos en la 3era pl...
 
A todo vapor con oracle forms & services laouc
A todo vapor con oracle forms & services laoucA todo vapor con oracle forms & services laouc
A todo vapor con oracle forms & services laouc
 
Charla técnica comercial v3.0 junio 2014 db visit productos
Charla técnica comercial v3.0 junio 2014 db visit productosCharla técnica comercial v3.0 junio 2014 db visit productos
Charla técnica comercial v3.0 junio 2014 db visit productos
 
Sociedades de conocimiento
Sociedades de conocimientoSociedades de conocimiento
Sociedades de conocimiento
 
Presentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12cPresentación Oracle Database Migración consideraciones 10g/11g/12c
Presentación Oracle Database Migración consideraciones 10g/11g/12c
 
Cedes cloud 2013 ronald vargas quesada
Cedes cloud 2013 ronald vargas quesadaCedes cloud 2013 ronald vargas quesada
Cedes cloud 2013 ronald vargas quesada
 
Oracle database 12c new features v1 2013 mayo
Oracle database 12c new features v1 2013 mayoOracle database 12c new features v1 2013 mayo
Oracle database 12c new features v1 2013 mayo
 

Último

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Último (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Performance tuning how to write correctly sql statement

  • 1. Performance Tuning: How to write correctly Ronald Vargas Quesada, Oracle ACE Expertise Database Management & Performance Technical PreSales Consultant, Netsoft de Centroamérica For Oracle employees and authorized partners only. Do not distribute to third parties. © 2012 Oracle Corporation – Proprietary and Confidential 1
  • 2. Performance Tuning: How to write correctly <function> ( <arg>,<arg>,..) OVER ( <partition clause> <sorting clause> <windowing clause> ) For Oracle employees and authorized partners only. Do not distribute to third parties. © 2012 Oracle Corporation – Proprietary and Confidential 2
  • 3. Performance Tuning: How to write correctly <function> ( <arg>,<arg>,..) OVER | KEEP | WITHING GROUP ( <partition clause> <sorting clause> <windowing clause> ) For Oracle employees and authorized partners only. Do not distribute to third parties. © 2012 Oracle Corporation – Proprietary and Confidential 3
  • 4. Performance Tuning: How to write correctly That´s it ! That´s it friends! For Oracle employees and authorized partners only. Do not distribute to third parties. © 2012 Oracle Corporation – Proprietary and Confidential 4
  • 5. Performance Tuning: How to write correctly quick example #1 For Oracle employees and authorized partners only. Do not distribute to third parties. © 2012 Oracle Corporation – Proprietary and Confidential 5
  • 6. employees by salary For Oracle employees and authorized partners only. Do not distribute to third parties. © 2012 Oracle Corporation – Proprietary and Confidential 6
  • 7. Performance Tuning: How to write correctly SQL> select employee_id, job_id, hire_date, salary 2 from employees 3 order by salary; EMPLOYEE_ID ----------132 136 128 127 135 191 119 140 144 182 131 JOB_ID ---------ST_CLERK ST_CLERK ST_CLERK ST_CLERK ST_CLERK SH_CLERK PU_CLERK ST_CLERK ST_CLERK SH_CLERK ST_CLERK HIRE_DATE SALARY --------- ---------10-APR-07 2100 06-FEB-08 2200 08-MAR-08 2200 14-JAN-07 2400 12-DEC-07 2400 19-DEC-07 2500 10-AUG-07 2500 06-APR-06 2500 09-JUL-06 2500 21-JUN-07 2500 16-FEB-05 2500 For Oracle employees and authorized partners only. Do not distribute to third parties. © 2012 Oracle Corporation – Proprietary and Confidential 7
  • 8. Performance Tuning: How to write correctly Who hired first ? hiring sequence For Oracle employees and authorized partners only. Do not distribute to third parties. © 2012 Oracle Corporation – Proprietary and Confidential 8
  • 9. Performance Tuning: How to write correctly 1 2 3 4 5 6 7 8* SQL> select e.employee_id, e.first_name, e.job_id, e.hire_date, e.salary, x.sequence from employees e, (select e2.employee_id, count(*) sequence from employees e1, employees e2 where e1.hire_date <= e2.hire_date group by e2.employee_id ) x where e.employee_id = x.employee_id order by salary / EMPLOYEE_ID ----------132 128 136 135 127 144 very complicated !! FIRST_NAME -------------------TJ Steven Hazel Ki James Peter JOB_ID ---------ST_CLERK ST_CLERK ST_CLERK ST_CLERK ST_CLERK ST_CLERK HIRE_DATE SALARY SEQUENCE --------- ---------- ---------10-APR-07 2100 85 08-MAR-08 2200 104 06-FEB-08 2200 102 12-DEC-07 2400 95 14-JAN-07 2400 78 09-JUL-06 2500 71 For Oracle employees and authorized partners only. Do not distribute to third parties. © 2012 Oracle Corporation – Proprietary and Confidential 9
  • 10. Performance Tuning: How to write correctly Is very simple ? For Oracle employees and authorized partners only. Do not distribute to third parties. © 2012 Oracle Corporation – Proprietary and Confidential 10
  • 11. Performance Tuning: How to write correctly Much or little work ? For Oracle employees and authorized partners only. Do not distribute to third parties. © 2012 Oracle Corporation – Proprietary and Confidential 11
  • 12. Performance Tuning: How to write correctly PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------Plan hash value: 2074273239 ------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 107 | 5243 | 14 (36)| 00:00:01 | | 1 | SORT ORDER BY | | 107 | 5243 | 14 (36)| 00:00:01 | |* 2 | HASH JOIN | | 107 | 5243 | 13 (31)| 00:00:01 | | 3 | TABLE ACCESS FULL | EMPLOYEES | 107 | 3424 | 3 (0)| 00:00:01 | | 4 | VIEW | | 107 | 1819 | 9 (34)| 00:00:01 | | 5 | HASH GROUP BY | | 107 | 2140 | 9 (34)| 00:00:01 | | 6 | MERGE JOIN | | 5783 | 112K| 8 (25)| 00:00:01 | | 7 | SORT JOIN | | 107 | 856 | 4 (25)| 00:00:01 | | 8 | TABLE ACCESS FULL| EMPLOYEES | 107 | 856 | 3 (0)| 00:00:01 | |* 9 | SORT JOIN | | 107 | 1284 | 4 (25)| 00:00:01 | | 10 | TABLE ACCESS FULL| EMPLOYEES | 107 | 1284 | 3 (0)| 00:00:01 | ------------------------------------------------------------------------------------Predicate Information (identified by operation id): --------------------------------------------------2 - access("E"."EMPLOYEE_ID"="X"."EMPLOYEE_ID") 9 - access("E1"."HIRE_DATE"<="E2"."HIRE_DATE") filter("E1"."HIRE_DATE"<="E2"."HIRE_DATE") 24 rows selected. For Oracle employees and authorized partners only. Do not distribute to third parties. © 2012 Oracle Corporation – Proprietary and Confidential 12
  • 13. Performance Tuning: How to write correctly Make it Simple !! For Oracle employees and authorized partners only. Do not distribute to third parties. © 2012 Oracle Corporation – Proprietary and Confidential 13
  • 14. Performance Tuning: How to write correctly SQL> select employee_id, first_name, job_id, hire_date, salary, rank() over (order by hire_date) as hire_seq 2 from employees 3 order by salary; EMPLOYEE_ID ----------132 136 128 127 135 131 140 144 FIRST_NAME -------------------TJ Hazel Steven James Ki James Joshua Peter JOB_ID ---------ST_CLERK ST_CLERK ST_CLERK ST_CLERK ST_CLERK ST_CLERK ST_CLERK ST_CLERK HIRE_DATE SALARY HIRE_SEQ --------- ---------- ---------10-APR-07 2100 85 06-FEB-08 2200 102 08-MAR-08 2200 104 14-JAN-07 2400 78 12-DEC-07 2400 95 16-FEB-05 2500 28 06-APR-06 2500 65 09-JUL-06 2500 71 For Oracle employees and authorized partners only. Do not distribute to third parties. © 2012 Oracle Corporation – Proprietary and Confidential 14
  • 15. Performance Tuning: How to write correctly SQL> select * from table(dbms_xplan.display); PLAN_TABLE_OUTPUT ---------------------------------------------------------------------------------Plan hash value: 1701542182 --------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | --------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 107 | 3424 | 5 (40)| 00:00:01 | | 1 | SORT ORDER BY | | 107 | 3424 | 5 (40)| 00:00:01 | | 2 | WINDOW SORT | | 107 | 3424 | 5 (40)| 00:00:01 | | 3 | TABLE ACCESS FULL| EMPLOYEES | 107 | 3424 | 3 (0)| 00:00:01 | --------------------------------------------------------------------------------10 rows selected. For Oracle employees and authorized partners only. Do not distribute to third parties. © 2012 Oracle Corporation – Proprietary and Confidential 15
  • 16. Performance Tuning: How to write correctly Not using bind variable SQL> host [oracle@LAB1 ~]$ vi script1.sql [oracle@LAB1 ~]$ more script1.sql set timing on begin for i in 1 .. 100000 loop execute immediate 'insert into t (x,y) values ( ' || i || ', ''x'') '; end loop; end; / [oracle@LAB1 ~]$ For Oracle employees and authorized partners only. Do not distribute to third parties. © 2012 Oracle Corporation – Proprietary and Confidential 16
  • 17. Performance Tuning: How to write correctly Using Bind variable [oracle@LAB1 ~]$ more script2.sql set timing on begin for i in 1 .. 100000 loop execute immediate 'insert into t (x,y) values ( :i, ''x'')' using i; end loop; end; / [oracle@LAB1 ~]$ For Oracle employees and authorized partners only. Do not distribute to third parties. © 2012 Oracle Corporation – Proprietary and Confidential 17
  • 18. @rovaque oracledbacr.blogspot.com ronald.vargas.quesada@gmail.com For Oracle employees and authorized partners only. Do not distribute to third parties. © 2012 Oracle Corporation – Proprietary and Confidential 18