SlideShare a Scribd company logo
Intorduction to the CBO Optimizer
1. CBO :Jonathan Lewis <<Cost-Based Oracle Fundamentals>>;
2. :
1. SQL ;
2. ;
3. ;
4. ;
3. :
1. DML(Data Manipulation Language):INSERT, UPDATE, DELETE, MERGE, SELECT;
2. DDL(Data Definition Language):CREATE, DROP, ALTER, RENAME, TRUNCATE, GRANT, REVOKE,
AUDIT, NOAUDIT, COMMENT;
3. ESS(Environmental Sustainability Statement):DECLARE, CONNECT, OPEN, CLOSE,
DESCRIBLE, WHENEVER, PREPARE, EXECUTE, FETCH;
4. TCS(Transactoin Control Statement):COMMIT, ROLLBACK, SAVEPOINT, SET TRANSACTION;
5. SystemCS(System Control Statement):ALTER SYSTEM;
6. SessionCS(Session Control Statement):ALTER SESSSION, SET ROLE;
4. SQL : SQL ;
5. Cursor
1. PL/SQL cursor: rowid, ;
2. sql cursor: SHARED POOL ;
6. SQL :
1. Create a cursor:
1. Cursor private SQL area ;
2. ;
3. Cursor SQL ;
2. Parse the statement:
1. SQL Oracle ;
2. PGA , , private SQL area, Library Cache
, , sql Shared SQL area , ;
3. SQL ;
3. Describe query results:
1. SELECT , SQL ;
2. 9i DBMS_SQL , EXECUTE IMMEDIATE SQL;
4. Define query output: , , ;
5. Bind variables:
1. ;
2. sql;
6. Parallelize the statement:
1. :SELECT, INSERT, UPDATE, MERGE, DELETE, CREATE, ALTER;
2. 11g ;
7. Execute the statement: SQL , ;
8. Fetch rows of a query: ;
9. Close the cursor: ,PGA cursor , , ;
10. DBMS_SQL SQL ;
7. SQL ;
8. : ;
9. :
10. Transformer
1. , ;
2. , SQL ;
3. OR UNION ALL ;
4. IN (11g);
5. IN exists;
6. NOT IN +IS NULL,11g ,10g ;
7. IN +IS NOT NULL;
8. : , , ;
9. : , .CBO , ;
10. Predicate Pushing: ;
11. :employees department_id ,department department_id ,
;
11. Cost-Based Optimizer
1. Estimator Plan Generator ;
2. Estimator ;
1. , ;
2. ;
3. Plan Generator:
1. ;
2. Estimator ;
3. ;
4. ;
4. OPTIMIZER_MODE :ALL_ROWS, FIRST_ROWS_n:
1. FIRST_ROWS_n:
1. CBO N , ;
2. BBS :SELECT /*+ first_rows(10) */ FROM tbname;
3. SQL , N ;
4. , CBO FIRST_ROWS(n), ALL_ROWS;
2. ALL_ROWS:
1. CBO , FIRST_ROWS_n ;
2. OLAP , ;
12. Estimator
1. Selectivity: ;
1. Selectivity is the estimated proportion of a row set retrieved by a particular
predicate or combination of predicates;
;
2. :Selectivity= / ;
3. 0.0-1.0 :
1. High Selectivity: ;
2. Low Selectivity: ;
4. Selectivity:
1. (Dynamic Sampling);
2. ;
5. :
1. dba_tables;
2. dba_tab_statistics(NUM_ROWS, BLOCKS, AVG_ROW_LEN);
3. dba_tab_col_statistics(NUM_DISTINCT, DENSITY, HIGH/LOW_VALUE);
2. Cardinality: ;
1. ;
2. :Cardinality=Selectivity* ;
3. join, filters sort ;
3. :SELECT * FROM hr.employees WHERE job_id = 'SH_CLERK';
1. employees job_id :19;
2. employees :107;
3. Selectivity=1/19=0.0526315789473684, DENSITY ;
4. Cardinality=(1/19)*107=5.63, 6;
4. Cost:
1. Cost I/Os ;
2. Cost :1 cost unit = 1 SRds(Standardized Random Reads);
3. Cost(%CPU): IO IO ;
4. Cost ;
13. :
1. CURSOR_SHARING:SIMILAR|EXACT(default)|FORCE, Cursor SQL ;
2. DB_FILE_MULTIBLOCK_READ_COUNT: IO , IO
;( OLTP 4-16, DW );
3. PGA_AGGREGATE_TARGET:PGA server processes PGA ;
4. STAR_TRANSFORMATION_ENABLED: TRUE CBO ,
;
5. RESULT_CACHE_MODE:MANUAL,FORCE,11g
6. RESULT_CACHE_MAX_SIZE:11g;
7. RESULT_CACHE_MAX_RESULT:11g;
8. RESULT_CACHE_REMOTE_EXPIRATION:11g;
9. OPTIMIZER_INDEX_CACHING: Buffer Cache , 0;
10. OPTIMIZER_INDEX_COST_ADJ: / , 100%, ;
; ;
11. OPTIMIZER_FEATURES_ENABLE: CBO;
12. OPTIMIZER_MODE:ALL_ROWS|FIRST_ROWS|FIRST_ROWS_n
1. all_rows: ;
2. first_rows_n:n 1|10|100|1000, , ;
13. OPTIMIZER_CAPTURE_SQL_PLAN_BASELINES;
14. OPTIMIZER_USE_SQL_PLAN_BASELINES;
15. OPTIMIZER_DYNAMIC_SAMPLING: ,10g 2;
16. OPTIMIZER_USE_INVISIBLE_INDEXES;
17. OPTIMIZER_USE_PENDING_STATISTICS;
14. OPTIMIZER_INDEX_COST_ADJ :
1. , , ;
2. , , 100%, , ;
3. 50, 1/2, ;
15. Selectivity :
1. CBO , Selectivity ;
2. 1200 , 1-12, 1-12 ;
3. , , 1/12, 100 ,CBO
;
4. , , ;
16. 10053 :
1. 10053 , sql ;
2. session_id process_id udump ;
3. udump , ;
4. 10053 ;
-- Estimator ;
SELECT * FROM hr.employees WHERE job_id = 'SH_CLERK';
SELECT COUNT(DISTINCT job_id) FROM hr.employees;
SELECT owner, table_name, column_name, num_distinct, density
FROM dba_tab_col_statistics
WHERE owner = 'HR' AND table_name = 'EMPLOYEES' AND column_name = 'JOB_ID';
SELECT owner, table_name, num_rows, blocks, avg_row_len
FROM dba_tab_statistics
WHERE owner = 'HR' AND table_name = 'EMPLOYEES';
-- OPTIMIZER_INDEX_COST_ADJ ;
CREATE TABLE t1 AS
SELECT MOD(ROWNUM, 200) n1, MOD(ROWNUM, 200) n2
FROM dba_objects WHERE ROWNUM <= 3000;
CREATE INDEX t_i1 ON t1(n1);
EXEC dbms_stats.gather_table_stats(USER, 't1', CASCADE=>TRUE);
SET autotrace traceonly exp;
SELECT * FROM t1 WHERE n1 = 50;
ALTER SESSION SET optimizer_index_cost_adj = 50;
SELECT * FROM t1 WHERE n1 = 50;
-- Selectivity ;
CREATE TABLE t2(ID, month_id) AS
SELECT ROWNUM, trunc(dbms_random.value(1, 13))
FROM dba_objects WHERE ROWNUM <= 1200;
EXEC dbms_stats.gather_table_stats(USER, 't2', CASCADE => TRUE);
SET autotrace traceonly exp;
SELECT * FROM t2 WHERE month_id = 5;
SELECT COUNT(*) FROM t2 WHERE month_id = 5;
-- 10053 ;
ALTER SYSTEM/SESSION SET EVENTS '10053 trace name context forever, level 8';
SELECT * FROM employees WHERE employee_id = 100;
ALTER SYSTEM/SESSION SET EVENTS '10053 trace name context off';
SELECT s.sid, p.spid FROM v$session s
INNER JOIN v$process p ON s.paddr = p.addr AND
s.sid = (SELECT sid FROM v$mystat WHERE ROWNUM = 1);
Ad

More Related Content

Similar to SQL Tuning02-Intorduction to the CBO Optimizer (20)

DBMS UNIT 9.pptx..................................
DBMS UNIT 9.pptx..................................DBMS UNIT 9.pptx..................................
DBMS UNIT 9.pptx..................................
VishwanathJustRockin
 
DOODB_LAB.pptx
DOODB_LAB.pptxDOODB_LAB.pptx
DOODB_LAB.pptx
FilestreamFilestream
 
How To Control IO Usage using Resource Manager
How To Control IO Usage using Resource ManagerHow To Control IO Usage using Resource Manager
How To Control IO Usage using Resource Manager
Alireza Kamrani
 
Cdc
CdcCdc
Cdc
Sabyasachi Srimany
 
My SQL.pptx
My SQL.pptxMy SQL.pptx
My SQL.pptx
KieveBarreto1
 
PL-SQL.pdf
PL-SQL.pdfPL-SQL.pdf
PL-SQL.pdf
Anas Nakash
 
CS3481_Database Management Laboratory .pdf
CS3481_Database Management Laboratory .pdfCS3481_Database Management Laboratory .pdf
CS3481_Database Management Laboratory .pdf
Kirubaburi R
 
SQL
SQLSQL
SQL
Srinath Reddy
 
Introduction to mysql part 3
Introduction to mysql part 3Introduction to mysql part 3
Introduction to mysql part 3
baabtra.com - No. 1 supplier of quality freshers
 
SQL
SQLSQL
SQL
Surendra Shukla
 
DBMS weSDFDDDFDFDFDSSek 4,5 BSCS 6th.pptx
DBMS weSDFDDDFDFDFDSSek 4,5 BSCS 6th.pptxDBMS weSDFDDDFDFDFDSSek 4,5 BSCS 6th.pptx
DBMS weSDFDDDFDFDFDSSek 4,5 BSCS 6th.pptx
universalcomputer1
 
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
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 Know
Alex Zaballa
 
kill_session_procedure.docx
kill_session_procedure.docxkill_session_procedure.docx
kill_session_procedure.docx
SUNIL884268
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
BhupendraShahi6
 
On Seeing Double in V$SQL_Thomas_Kytepdf
On Seeing Double in V$SQL_Thomas_KytepdfOn Seeing Double in V$SQL_Thomas_Kytepdf
On Seeing Double in V$SQL_Thomas_Kytepdf
cookie1969
 
Oracle training in hyderabad
Oracle training in hyderabadOracle training in hyderabad
Oracle training in hyderabad
Kelly Technologies
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SabrinaShanta2
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SaiMiryala1
 
Oracle tips and tricks
Oracle tips and tricksOracle tips and tricks
Oracle tips and tricks
Yanli Liu
 
DBMS UNIT 9.pptx..................................
DBMS UNIT 9.pptx..................................DBMS UNIT 9.pptx..................................
DBMS UNIT 9.pptx..................................
VishwanathJustRockin
 
How To Control IO Usage using Resource Manager
How To Control IO Usage using Resource ManagerHow To Control IO Usage using Resource Manager
How To Control IO Usage using Resource Manager
Alireza Kamrani
 
CS3481_Database Management Laboratory .pdf
CS3481_Database Management Laboratory .pdfCS3481_Database Management Laboratory .pdf
CS3481_Database Management Laboratory .pdf
Kirubaburi R
 
DBMS weSDFDDDFDFDFDSSek 4,5 BSCS 6th.pptx
DBMS weSDFDDDFDFDFDSSek 4,5 BSCS 6th.pptxDBMS weSDFDDDFDFDFDSSek 4,5 BSCS 6th.pptx
DBMS weSDFDDDFDFDFDSSek 4,5 BSCS 6th.pptx
universalcomputer1
 
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
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 Know
Alex Zaballa
 
kill_session_procedure.docx
kill_session_procedure.docxkill_session_procedure.docx
kill_session_procedure.docx
SUNIL884268
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
BhupendraShahi6
 
On Seeing Double in V$SQL_Thomas_Kytepdf
On Seeing Double in V$SQL_Thomas_KytepdfOn Seeing Double in V$SQL_Thomas_Kytepdf
On Seeing Double in V$SQL_Thomas_Kytepdf
cookie1969
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SabrinaShanta2
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SaiMiryala1
 
Oracle tips and tricks
Oracle tips and tricksOracle tips and tricks
Oracle tips and tricks
Yanli Liu
 

More from Zhaoyang Wang (20)

海通证券金融云思考与实践(数据技术嘉年华2017)
海通证券金融云思考与实践(数据技术嘉年华2017)海通证券金融云思考与实践(数据技术嘉年华2017)
海通证券金融云思考与实践(数据技术嘉年华2017)
Zhaoyang Wang
 
云管理平台助力海通金融云建设
云管理平台助力海通金融云建设云管理平台助力海通金融云建设
云管理平台助力海通金融云建设
Zhaoyang Wang
 
海通证券数据库备份恢复云平台实践(OTN Tour Shanghai 2017)
海通证券数据库备份恢复云平台实践(OTN Tour Shanghai 2017)海通证券数据库备份恢复云平台实践(OTN Tour Shanghai 2017)
海通证券数据库备份恢复云平台实践(OTN Tour Shanghai 2017)
Zhaoyang Wang
 
Oracle Compute Cloud Service快速实践
Oracle Compute Cloud Service快速实践Oracle Compute Cloud Service快速实践
Oracle Compute Cloud Service快速实践
Zhaoyang Wang
 
Oracle Compute Cloud Service介绍
Oracle Compute Cloud Service介绍Oracle Compute Cloud Service介绍
Oracle Compute Cloud Service介绍
Zhaoyang Wang
 
Oracle cloud 使用云市场快速搭建小型电商网站
Oracle cloud 使用云市场快速搭建小型电商网站Oracle cloud 使用云市场快速搭建小型电商网站
Oracle cloud 使用云市场快速搭建小型电商网站
Zhaoyang Wang
 
Oracle cloud ravello介绍及测试账户申请
Oracle cloud ravello介绍及测试账户申请Oracle cloud ravello介绍及测试账户申请
Oracle cloud ravello介绍及测试账户申请
Zhaoyang Wang
 
Oracle cloud 云介绍及测试账户申请
Oracle cloud 云介绍及测试账户申请Oracle cloud 云介绍及测试账户申请
Oracle cloud 云介绍及测试账户申请
Zhaoyang Wang
 
New awesome features in MySQL 5.7
New awesome features in MySQL 5.7New awesome features in MySQL 5.7
New awesome features in MySQL 5.7
Zhaoyang Wang
 
Performance Tuning Tool01-Statspack
Performance Tuning Tool01-StatspackPerformance Tuning Tool01-Statspack
Performance Tuning Tool01-Statspack
Zhaoyang Wang
 
SQL Tuning04-Interpreting Execution Plans
SQL Tuning04-Interpreting Execution PlansSQL Tuning04-Interpreting Execution Plans
SQL Tuning04-Interpreting Execution Plans
Zhaoyang Wang
 
SQL Tuning01-Introduction to SQL Tuning
SQL Tuning01-Introduction to SQL TuningSQL Tuning01-Introduction to SQL Tuning
SQL Tuning01-Introduction to SQL Tuning
Zhaoyang Wang
 
MySQL Fulltext Search Tutorial
MySQL Fulltext Search TutorialMySQL Fulltext Search Tutorial
MySQL Fulltext Search Tutorial
Zhaoyang Wang
 
Data Organization in InnoDB
Data Organization in InnoDBData Organization in InnoDB
Data Organization in InnoDB
Zhaoyang Wang
 
Oracle enterprise manager cloud control 12c release 5 installation on oracle ...
Oracle enterprise manager cloud control 12c release 5 installation on oracle ...Oracle enterprise manager cloud control 12c release 5 installation on oracle ...
Oracle enterprise manager cloud control 12c release 5 installation on oracle ...
Zhaoyang Wang
 
Oracle enterprise manager cloud control 12c r5 agent installation
Oracle enterprise manager cloud control 12c r5 agent installationOracle enterprise manager cloud control 12c r5 agent installation
Oracle enterprise manager cloud control 12c r5 agent installation
Zhaoyang Wang
 
MYSQLCLONE Introduction
MYSQLCLONE IntroductionMYSQLCLONE Introduction
MYSQLCLONE Introduction
Zhaoyang Wang
 
Oracle security 08-oracle network security
Oracle security 08-oracle network securityOracle security 08-oracle network security
Oracle security 08-oracle network security
Zhaoyang Wang
 
Oracle security 02-administering user security
Oracle security 02-administering user securityOracle security 02-administering user security
Oracle security 02-administering user security
Zhaoyang Wang
 
海通证券金融云思考与实践(数据技术嘉年华2017)
海通证券金融云思考与实践(数据技术嘉年华2017)海通证券金融云思考与实践(数据技术嘉年华2017)
海通证券金融云思考与实践(数据技术嘉年华2017)
Zhaoyang Wang
 
云管理平台助力海通金融云建设
云管理平台助力海通金融云建设云管理平台助力海通金融云建设
云管理平台助力海通金融云建设
Zhaoyang Wang
 
海通证券数据库备份恢复云平台实践(OTN Tour Shanghai 2017)
海通证券数据库备份恢复云平台实践(OTN Tour Shanghai 2017)海通证券数据库备份恢复云平台实践(OTN Tour Shanghai 2017)
海通证券数据库备份恢复云平台实践(OTN Tour Shanghai 2017)
Zhaoyang Wang
 
Oracle Compute Cloud Service快速实践
Oracle Compute Cloud Service快速实践Oracle Compute Cloud Service快速实践
Oracle Compute Cloud Service快速实践
Zhaoyang Wang
 
Oracle Compute Cloud Service介绍
Oracle Compute Cloud Service介绍Oracle Compute Cloud Service介绍
Oracle Compute Cloud Service介绍
Zhaoyang Wang
 
Oracle cloud 使用云市场快速搭建小型电商网站
Oracle cloud 使用云市场快速搭建小型电商网站Oracle cloud 使用云市场快速搭建小型电商网站
Oracle cloud 使用云市场快速搭建小型电商网站
Zhaoyang Wang
 
Oracle cloud ravello介绍及测试账户申请
Oracle cloud ravello介绍及测试账户申请Oracle cloud ravello介绍及测试账户申请
Oracle cloud ravello介绍及测试账户申请
Zhaoyang Wang
 
Oracle cloud 云介绍及测试账户申请
Oracle cloud 云介绍及测试账户申请Oracle cloud 云介绍及测试账户申请
Oracle cloud 云介绍及测试账户申请
Zhaoyang Wang
 
New awesome features in MySQL 5.7
New awesome features in MySQL 5.7New awesome features in MySQL 5.7
New awesome features in MySQL 5.7
Zhaoyang Wang
 
Performance Tuning Tool01-Statspack
Performance Tuning Tool01-StatspackPerformance Tuning Tool01-Statspack
Performance Tuning Tool01-Statspack
Zhaoyang Wang
 
SQL Tuning04-Interpreting Execution Plans
SQL Tuning04-Interpreting Execution PlansSQL Tuning04-Interpreting Execution Plans
SQL Tuning04-Interpreting Execution Plans
Zhaoyang Wang
 
SQL Tuning01-Introduction to SQL Tuning
SQL Tuning01-Introduction to SQL TuningSQL Tuning01-Introduction to SQL Tuning
SQL Tuning01-Introduction to SQL Tuning
Zhaoyang Wang
 
MySQL Fulltext Search Tutorial
MySQL Fulltext Search TutorialMySQL Fulltext Search Tutorial
MySQL Fulltext Search Tutorial
Zhaoyang Wang
 
Data Organization in InnoDB
Data Organization in InnoDBData Organization in InnoDB
Data Organization in InnoDB
Zhaoyang Wang
 
Oracle enterprise manager cloud control 12c release 5 installation on oracle ...
Oracle enterprise manager cloud control 12c release 5 installation on oracle ...Oracle enterprise manager cloud control 12c release 5 installation on oracle ...
Oracle enterprise manager cloud control 12c release 5 installation on oracle ...
Zhaoyang Wang
 
Oracle enterprise manager cloud control 12c r5 agent installation
Oracle enterprise manager cloud control 12c r5 agent installationOracle enterprise manager cloud control 12c r5 agent installation
Oracle enterprise manager cloud control 12c r5 agent installation
Zhaoyang Wang
 
MYSQLCLONE Introduction
MYSQLCLONE IntroductionMYSQLCLONE Introduction
MYSQLCLONE Introduction
Zhaoyang Wang
 
Oracle security 08-oracle network security
Oracle security 08-oracle network securityOracle security 08-oracle network security
Oracle security 08-oracle network security
Zhaoyang Wang
 
Oracle security 02-administering user security
Oracle security 02-administering user securityOracle security 02-administering user security
Oracle security 02-administering user security
Zhaoyang Wang
 
Ad

Recently uploaded (20)

Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Ad

SQL Tuning02-Intorduction to the CBO Optimizer

  • 1. Intorduction to the CBO Optimizer 1. CBO :Jonathan Lewis <<Cost-Based Oracle Fundamentals>>; 2. : 1. SQL ; 2. ; 3. ; 4. ; 3. : 1. DML(Data Manipulation Language):INSERT, UPDATE, DELETE, MERGE, SELECT; 2. DDL(Data Definition Language):CREATE, DROP, ALTER, RENAME, TRUNCATE, GRANT, REVOKE, AUDIT, NOAUDIT, COMMENT; 3. ESS(Environmental Sustainability Statement):DECLARE, CONNECT, OPEN, CLOSE, DESCRIBLE, WHENEVER, PREPARE, EXECUTE, FETCH; 4. TCS(Transactoin Control Statement):COMMIT, ROLLBACK, SAVEPOINT, SET TRANSACTION; 5. SystemCS(System Control Statement):ALTER SYSTEM; 6. SessionCS(Session Control Statement):ALTER SESSSION, SET ROLE; 4. SQL : SQL ; 5. Cursor 1. PL/SQL cursor: rowid, ; 2. sql cursor: SHARED POOL ; 6. SQL : 1. Create a cursor: 1. Cursor private SQL area ; 2. ; 3. Cursor SQL ; 2. Parse the statement: 1. SQL Oracle ; 2. PGA , , private SQL area, Library Cache , , sql Shared SQL area , ; 3. SQL ; 3. Describe query results: 1. SELECT , SQL ; 2. 9i DBMS_SQL , EXECUTE IMMEDIATE SQL; 4. Define query output: , , ; 5. Bind variables: 1. ; 2. sql; 6. Parallelize the statement: 1. :SELECT, INSERT, UPDATE, MERGE, DELETE, CREATE, ALTER; 2. 11g ; 7. Execute the statement: SQL , ; 8. Fetch rows of a query: ; 9. Close the cursor: ,PGA cursor , , ; 10. DBMS_SQL SQL ; 7. SQL ; 8. : ; 9. : 10. Transformer 1. , ; 2. , SQL ; 3. OR UNION ALL ; 4. IN (11g); 5. IN exists; 6. NOT IN +IS NULL,11g ,10g ; 7. IN +IS NOT NULL; 8. : , , ; 9. : , .CBO , ; 10. Predicate Pushing: ; 11. :employees department_id ,department department_id , ; 11. Cost-Based Optimizer 1. Estimator Plan Generator ; 2. Estimator ; 1. , ; 2. ; 3. Plan Generator: 1. ; 2. Estimator ; 3. ; 4. ; 4. OPTIMIZER_MODE :ALL_ROWS, FIRST_ROWS_n: 1. FIRST_ROWS_n: 1. CBO N , ; 2. BBS :SELECT /*+ first_rows(10) */ FROM tbname; 3. SQL , N ; 4. , CBO FIRST_ROWS(n), ALL_ROWS; 2. ALL_ROWS: 1. CBO , FIRST_ROWS_n ; 2. OLAP , ; 12. Estimator 1. Selectivity: ; 1. Selectivity is the estimated proportion of a row set retrieved by a particular predicate or combination of predicates; ; 2. :Selectivity= / ; 3. 0.0-1.0 : 1. High Selectivity: ; 2. Low Selectivity: ; 4. Selectivity: 1. (Dynamic Sampling); 2. ; 5. : 1. dba_tables; 2. dba_tab_statistics(NUM_ROWS, BLOCKS, AVG_ROW_LEN); 3. dba_tab_col_statistics(NUM_DISTINCT, DENSITY, HIGH/LOW_VALUE); 2. Cardinality: ; 1. ; 2. :Cardinality=Selectivity* ; 3. join, filters sort ; 3. :SELECT * FROM hr.employees WHERE job_id = 'SH_CLERK'; 1. employees job_id :19; 2. employees :107; 3. Selectivity=1/19=0.0526315789473684, DENSITY ; 4. Cardinality=(1/19)*107=5.63, 6; 4. Cost: 1. Cost I/Os ; 2. Cost :1 cost unit = 1 SRds(Standardized Random Reads); 3. Cost(%CPU): IO IO ; 4. Cost ; 13. : 1. CURSOR_SHARING:SIMILAR|EXACT(default)|FORCE, Cursor SQL ; 2. DB_FILE_MULTIBLOCK_READ_COUNT: IO , IO ;( OLTP 4-16, DW ); 3. PGA_AGGREGATE_TARGET:PGA server processes PGA ; 4. STAR_TRANSFORMATION_ENABLED: TRUE CBO , ; 5. RESULT_CACHE_MODE:MANUAL,FORCE,11g 6. RESULT_CACHE_MAX_SIZE:11g; 7. RESULT_CACHE_MAX_RESULT:11g; 8. RESULT_CACHE_REMOTE_EXPIRATION:11g; 9. OPTIMIZER_INDEX_CACHING: Buffer Cache , 0; 10. OPTIMIZER_INDEX_COST_ADJ: / , 100%, ; ; ; 11. OPTIMIZER_FEATURES_ENABLE: CBO; 12. OPTIMIZER_MODE:ALL_ROWS|FIRST_ROWS|FIRST_ROWS_n 1. all_rows: ; 2. first_rows_n:n 1|10|100|1000, , ; 13. OPTIMIZER_CAPTURE_SQL_PLAN_BASELINES; 14. OPTIMIZER_USE_SQL_PLAN_BASELINES; 15. OPTIMIZER_DYNAMIC_SAMPLING: ,10g 2; 16. OPTIMIZER_USE_INVISIBLE_INDEXES; 17. OPTIMIZER_USE_PENDING_STATISTICS; 14. OPTIMIZER_INDEX_COST_ADJ : 1. , , ; 2. , , 100%, , ; 3. 50, 1/2, ; 15. Selectivity : 1. CBO , Selectivity ; 2. 1200 , 1-12, 1-12 ; 3. , , 1/12, 100 ,CBO ; 4. , , ; 16. 10053 : 1. 10053 , sql ; 2. session_id process_id udump ; 3. udump , ; 4. 10053 ; -- Estimator ; SELECT * FROM hr.employees WHERE job_id = 'SH_CLERK'; SELECT COUNT(DISTINCT job_id) FROM hr.employees; SELECT owner, table_name, column_name, num_distinct, density FROM dba_tab_col_statistics WHERE owner = 'HR' AND table_name = 'EMPLOYEES' AND column_name = 'JOB_ID'; SELECT owner, table_name, num_rows, blocks, avg_row_len FROM dba_tab_statistics WHERE owner = 'HR' AND table_name = 'EMPLOYEES'; -- OPTIMIZER_INDEX_COST_ADJ ; CREATE TABLE t1 AS SELECT MOD(ROWNUM, 200) n1, MOD(ROWNUM, 200) n2 FROM dba_objects WHERE ROWNUM <= 3000; CREATE INDEX t_i1 ON t1(n1); EXEC dbms_stats.gather_table_stats(USER, 't1', CASCADE=>TRUE); SET autotrace traceonly exp; SELECT * FROM t1 WHERE n1 = 50; ALTER SESSION SET optimizer_index_cost_adj = 50; SELECT * FROM t1 WHERE n1 = 50; -- Selectivity ; CREATE TABLE t2(ID, month_id) AS SELECT ROWNUM, trunc(dbms_random.value(1, 13)) FROM dba_objects WHERE ROWNUM <= 1200; EXEC dbms_stats.gather_table_stats(USER, 't2', CASCADE => TRUE); SET autotrace traceonly exp; SELECT * FROM t2 WHERE month_id = 5; SELECT COUNT(*) FROM t2 WHERE month_id = 5; -- 10053 ; ALTER SYSTEM/SESSION SET EVENTS '10053 trace name context forever, level 8'; SELECT * FROM employees WHERE employee_id = 100; ALTER SYSTEM/SESSION SET EVENTS '10053 trace name context off'; SELECT s.sid, p.spid FROM v$session s INNER JOIN v$process p ON s.paddr = p.addr AND s.sid = (SELECT sid FROM v$mystat WHERE ROWNUM = 1);