SlideShare ist ein Scribd-Unternehmen logo
1 von 21
Cost-Based Query Transformation in
Oracle
Presented by Yuanjia Zhang
Problem to Solve
Tranditional query optimization(in 2006) consists of two phases:
● logical phase: query is rewritten based on heuristic rules.
● physical phase: best implementations are chosen based on cost
estimation.
Some heuristic rules in logical phase should be made in a cost-based manner.
For example:
● Join Reorder
● Group-By Placement
● Subquery Unnesting
● ...
Problem to Solve
A Subquery Unnesting Example
Join SubQuery
Apply
e1 j
Join
e1 jAgg
Overview
● Transformation in Oracle
○ Heuristic Transformations
○ Cost-Based Transformations
● Cost-Based Transformation Framework
○ Overview
○ State Space Search Techniques
○ Interaction between Transformations
○ Optimization Performance
● Performance Study
Heuristic Transformation in Oracle
Subquery Unnesting
Two categories of subquery unnesting:
● unnesting that generates inline views.
● unnesting that merges a subquery into its outer query.
Note that dept_id in employees is a foreign key that references the primary key of departments.
Join
d e
d e
Apply
Heuristic Transformation in Oracle
Join Elimination
Remove tables from a query if there are constraints on the join columns.
Note that dept_id in employees is a foreign key that references the primary key of departments.
Heuristic Transformation in Oracle
Group Pruning
Remove views groups not needed in the outer query blocks.
Cost-Based Transformation in Oracle
Subquery Unnesting
Two categories of subquery unnesting:
● unnesting that generates inline views.
● unnesting that merges a subquery into its outer query.
Join SubQuery
Apply
e1 j
Join
e1 jAgg
Cost-Based Transformation in Oracle
Group-By and Distinct View Merging
Merge view contains group-by or distinct into its outer query block.
Join
e1 jAgg
e2
Join
e1 j
Agg
e2
Cost-Based Transformation in Oracle
Join Predicate Pushdown
Push join predicates into a view.
Join
e1 jAgg e1 j
NestJoin/Apply
l
Cost-Based Transformation in Oracle
Join Factorization
Pull common join tables up to the outer UNION ALL query block.
Union
l
Join Join
de jd el
Union
Join
Join
d
e
je
l
Cost-Based Transformation in Oracle
Expensive Predicate Pullup
Pull expensive predicates up from the originating view to outer query block.
A predicate is considered expensive if it contains
● procedural language,
● user-defined operators,
● subqueries.
This transformation is only considered when rownum(limit) predicate is specified.
Cost-Based Transformation Framework
PhysicalOptimization Component is used to:
● estimate query tree cost,
● generate the final physical execution plan.
The order of applying transformations matters,
so...
common sub-expression factorization, SPJ view
merging, join elimination, subquery unnesting,
group-by (distinct) view merging, group
pruning, predicate move around, set operator
into join conversion, group-by placement,
predicate pullup, join factorization,
disjunction into union-all expansion, star
transformation, and join predicate pushdown
State Space Search Techniques
Definition of state in search space
We have a query consists of N objects(e.g., tables, join edges, predicats, etc.),
and we have M transformatins that can apply on the N objects,
then the state is represented by an M*N bit matrix and
there are 2^(M*N) states totally.
If we only have one transformation, expensive predicate pullup,
then the SQL below have four states:
● [[0, 0]],
● [[0, 1]],
● [[1, 0]],
● [[1, 1]].
State Space Search Techniques
How to search in state space
Four different techniques(only consider one transformation):
● Exhaustive: all 2^N states for N objects are considered.
● Two-pass: only consider 2 states, [[0, 0, ...0]] and [[1, 1, ...1]].
● Linear: a dynamic programming approach that suppose different objects are
independent; N+1 states are considered.
● Iterative:
a. start from an initial state and look for a local minimum state.
b. choose a different initial state and repeat step a until
■ no more new states to be found, or
■ some terminatin condition has been reached.
c. N+1~2^N states are considered.
Interaction between Transformations
Interleaving
When two (or more) cost-based transformations apply on the same object such that one
transformation becomes applicable only after the other has been applied, then these
transformations must be interleaved in order for the optimizer to determine the optimal plan.
We begin at S0, and
we can apply T1 to S1 and
we can apply T2, T3 to S2, S3;
If we don’t interleave T3 after T2, we can’t get to
S3 and the best state Sfinal on the right.
Interaction between Transformations
Juxtaposition
When two or more cost-based transformations apply on the same object in a way that precludes
their sequential application, they must be applied one by one in order for the optimizer to
determine the most optimal plan. This comparison of two or more cost-based transformations is
called juxtaposition.
We begin at S0, and
we can apply T1 to S1 or T2 to S2 but
T1 < T2 in sequential order and
we know if we get to S1,
we can’t get to S2 probably.
If we don’t consider T2 when we apply T1, we can’t
get to S2 and the best state Sfinal on the right.
Interaction between Transformations
Juxtaposition
An example: view merging and join predicate push down must be juxtaposed with each other.
Join
e1 jAgge1 jAgg
NestJoin/Apply
Join
e1 j
Agg
e2
view mergingJPPD
Optimization Performance
Reuse of Query Sub-Tree Cost Annotations
We have a query with two subquery and
a transformation which can be applied on subquery.
Then we have four states:
Cost information of Qs1, Qs2, T(Qs1), T(Qs2) can be used.
Performance Study
Dataset
● 14000 tables representing HR, Financial, Order Entry, CRM, Supply Chain…
● 241000 queries
○ the average number of tables in a query is 8,
○ most of the queries are of simple Sel/Proj/Join type,
○ 8% of these queries have subqueries, GROUP-BY, DISTINCT or UNION ALL.
Result
● 5910 execution plans changed.
● the total run time improved by 20% on
average.
● 18% affected queries degraded by 40%.
● the top 5% of longest running queries
improved 27%.
● optimization time increased by only 40%.
Any Questions ?
关注 PingCAP 官方微信
了解更多技术干货
Thank You!

Weitere ähnliche Inhalte

Was ist angesagt?

Applications of analytic functions and vector calculus
Applications of analytic functions and vector calculusApplications of analytic functions and vector calculus
Applications of analytic functions and vector calculusPoojith Chowdhary
 
MODULE 5-Searching and-sorting
MODULE 5-Searching and-sortingMODULE 5-Searching and-sorting
MODULE 5-Searching and-sortingnikshaikh786
 
composing procedures
composing procedurescomposing procedures
composing proceduresRajendran
 
Parallel First-Order Operations
Parallel First-Order OperationsParallel First-Order Operations
Parallel First-Order OperationsSina Madani
 
recursive problem_solving
recursive problem_solvingrecursive problem_solving
recursive problem_solvingRajendran
 
Sql Server Query Parameterization
Sql Server Query ParameterizationSql Server Query Parameterization
Sql Server Query ParameterizationMindfire Solutions
 
Parallel Algorithms- Sorting and Graph
Parallel Algorithms- Sorting and GraphParallel Algorithms- Sorting and Graph
Parallel Algorithms- Sorting and GraphDr Shashikant Athawale
 
Quicksort Algorithm..simply defined through animations..!!
Quicksort Algorithm..simply defined through animations..!!Quicksort Algorithm..simply defined through animations..!!
Quicksort Algorithm..simply defined through animations..!!Mahesh Tibrewal
 
A Benchmark for Interpretability Methods in Deep Neural Networks
A Benchmark for Interpretability Methods in Deep Neural NetworksA Benchmark for Interpretability Methods in Deep Neural Networks
A Benchmark for Interpretability Methods in Deep Neural NetworksSungchul Kim
 
Unit ii divide and conquer -1
Unit ii divide and conquer -1Unit ii divide and conquer -1
Unit ii divide and conquer -1subhashchandra197
 
Graph-to-Graph Transformer for Transition-based Dependency Parsing
Graph-to-Graph Transformer for Transition-based Dependency ParsingGraph-to-Graph Transformer for Transition-based Dependency Parsing
Graph-to-Graph Transformer for Transition-based Dependency ParsingAlireza Mohammadshahi
 
Complexity of algorithms
Complexity of algorithmsComplexity of algorithms
Complexity of algorithmsJasur Ahmadov
 
Lec 2 algorithms efficiency complexity
Lec 2 algorithms efficiency  complexityLec 2 algorithms efficiency  complexity
Lec 2 algorithms efficiency complexityAnaya Zafar
 

Was ist angesagt? (20)

Applications of analytic functions and vector calculus
Applications of analytic functions and vector calculusApplications of analytic functions and vector calculus
Applications of analytic functions and vector calculus
 
MODULE 5-Searching and-sorting
MODULE 5-Searching and-sortingMODULE 5-Searching and-sorting
MODULE 5-Searching and-sorting
 
composing procedures
composing procedurescomposing procedures
composing procedures
 
Parallel First-Order Operations
Parallel First-Order OperationsParallel First-Order Operations
Parallel First-Order Operations
 
recursive problem_solving
recursive problem_solvingrecursive problem_solving
recursive problem_solving
 
Sql Server Query Parameterization
Sql Server Query ParameterizationSql Server Query Parameterization
Sql Server Query Parameterization
 
Chap06alg
Chap06algChap06alg
Chap06alg
 
Chap06alg
Chap06algChap06alg
Chap06alg
 
Parallel Algorithms- Sorting and Graph
Parallel Algorithms- Sorting and GraphParallel Algorithms- Sorting and Graph
Parallel Algorithms- Sorting and Graph
 
Bs,qs,divide and conquer 1
Bs,qs,divide and conquer 1Bs,qs,divide and conquer 1
Bs,qs,divide and conquer 1
 
Quicksort Algorithm..simply defined through animations..!!
Quicksort Algorithm..simply defined through animations..!!Quicksort Algorithm..simply defined through animations..!!
Quicksort Algorithm..simply defined through animations..!!
 
Rseminarp
RseminarpRseminarp
Rseminarp
 
A Benchmark for Interpretability Methods in Deep Neural Networks
A Benchmark for Interpretability Methods in Deep Neural NetworksA Benchmark for Interpretability Methods in Deep Neural Networks
A Benchmark for Interpretability Methods in Deep Neural Networks
 
Quick sort
Quick sortQuick sort
Quick sort
 
Unit ii divide and conquer -1
Unit ii divide and conquer -1Unit ii divide and conquer -1
Unit ii divide and conquer -1
 
Graph-to-Graph Transformer for Transition-based Dependency Parsing
Graph-to-Graph Transformer for Transition-based Dependency ParsingGraph-to-Graph Transformer for Transition-based Dependency Parsing
Graph-to-Graph Transformer for Transition-based Dependency Parsing
 
Complexity of algorithms
Complexity of algorithmsComplexity of algorithms
Complexity of algorithms
 
Lec 2 algorithms efficiency complexity
Lec 2 algorithms efficiency  complexityLec 2 algorithms efficiency  complexity
Lec 2 algorithms efficiency complexity
 
Merge sort
Merge sortMerge sort
Merge sort
 
Seminar@KRDB 2012 - Montali - Verification of Relational Data-Centric Systems...
Seminar@KRDB 2012 - Montali - Verification of Relational Data-Centric Systems...Seminar@KRDB 2012 - Montali - Verification of Relational Data-Centric Systems...
Seminar@KRDB 2012 - Montali - Verification of Relational Data-Centric Systems...
 

Ähnlich wie Paper reading: Cost-based Query Transformation in Oracle

From Declarative to Imperative Operation Specifications (ER 2007)
From Declarative to Imperative Operation Specifications (ER 2007)From Declarative to Imperative Operation Specifications (ER 2007)
From Declarative to Imperative Operation Specifications (ER 2007)Jordi Cabot
 
Predictable reactive state management - ngrx
Predictable reactive state management - ngrxPredictable reactive state management - ngrx
Predictable reactive state management - ngrxIlia Idakiev
 
A brief introduction to Searn Algorithm
A brief introduction to Searn AlgorithmA brief introduction to Searn Algorithm
A brief introduction to Searn AlgorithmSupun Abeysinghe
 
RPA Summer School Studio Session 2 - The Fundamentals of UiPath Studio .pdf
RPA Summer School Studio Session 2 - The Fundamentals of UiPath Studio .pdfRPA Summer School Studio Session 2 - The Fundamentals of UiPath Studio .pdf
RPA Summer School Studio Session 2 - The Fundamentals of UiPath Studio .pdfCristina Vidu
 
UiPath Studio Session 2 - The Fundamentals of UiPath Studio - Final Slides.pdf
UiPath Studio Session 2 - The Fundamentals of UiPath Studio - Final Slides.pdfUiPath Studio Session 2 - The Fundamentals of UiPath Studio - Final Slides.pdf
UiPath Studio Session 2 - The Fundamentals of UiPath Studio - Final Slides.pdfDiana Gray, MBA
 
Refactoring: Improving the design of existing code
Refactoring: Improving the design of existing codeRefactoring: Improving the design of existing code
Refactoring: Improving the design of existing codeKnoldus Inc.
 
Apache Calcite: One Frontend to Rule Them All
Apache Calcite: One Frontend to Rule Them AllApache Calcite: One Frontend to Rule Them All
Apache Calcite: One Frontend to Rule Them AllMichael Mior
 
Important Concepts for Machine Learning
Important Concepts for Machine LearningImportant Concepts for Machine Learning
Important Concepts for Machine LearningSolivarLabs
 
Transaction Management, Recovery and Query Processing.pptx
Transaction Management, Recovery and Query Processing.pptxTransaction Management, Recovery and Query Processing.pptx
Transaction Management, Recovery and Query Processing.pptxRoshni814224
 
Understanding React hooks | Walkingtree Technologies
Understanding React hooks | Walkingtree TechnologiesUnderstanding React hooks | Walkingtree Technologies
Understanding React hooks | Walkingtree TechnologiesWalking Tree Technologies
 
Machine Learning.pdf
Machine Learning.pdfMachine Learning.pdf
Machine Learning.pdfBeyaNasr1
 
Ch24 efficient algorithms
Ch24 efficient algorithmsCh24 efficient algorithms
Ch24 efficient algorithmsrajatmay1992
 
An efficient use of temporal difference technique in Computer Game Learning
An efficient use of temporal difference technique in Computer Game LearningAn efficient use of temporal difference technique in Computer Game Learning
An efficient use of temporal difference technique in Computer Game LearningPrabhu Kumar
 
Layout planning
Layout planningLayout planning
Layout planning8979473684
 
Concepts of predictive control
Concepts of predictive controlConcepts of predictive control
Concepts of predictive controlJARossiter
 
Chapter 3.Simplex Method hand out last.pdf
Chapter 3.Simplex Method hand out last.pdfChapter 3.Simplex Method hand out last.pdf
Chapter 3.Simplex Method hand out last.pdfTsegay Berhe
 
Reinforcement learning:policy gradient (part 1)
Reinforcement learning:policy gradient (part 1)Reinforcement learning:policy gradient (part 1)
Reinforcement learning:policy gradient (part 1)Bean Yen
 
Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysissumitbardhan
 

Ähnlich wie Paper reading: Cost-based Query Transformation in Oracle (20)

Oracle SQL Advanced
Oracle SQL AdvancedOracle SQL Advanced
Oracle SQL Advanced
 
From Declarative to Imperative Operation Specifications (ER 2007)
From Declarative to Imperative Operation Specifications (ER 2007)From Declarative to Imperative Operation Specifications (ER 2007)
From Declarative to Imperative Operation Specifications (ER 2007)
 
Predictable reactive state management - ngrx
Predictable reactive state management - ngrxPredictable reactive state management - ngrx
Predictable reactive state management - ngrx
 
A brief introduction to Searn Algorithm
A brief introduction to Searn AlgorithmA brief introduction to Searn Algorithm
A brief introduction to Searn Algorithm
 
RPA Summer School Studio Session 2 - The Fundamentals of UiPath Studio .pdf
RPA Summer School Studio Session 2 - The Fundamentals of UiPath Studio .pdfRPA Summer School Studio Session 2 - The Fundamentals of UiPath Studio .pdf
RPA Summer School Studio Session 2 - The Fundamentals of UiPath Studio .pdf
 
UiPath Studio Session 2 - The Fundamentals of UiPath Studio - Final Slides.pdf
UiPath Studio Session 2 - The Fundamentals of UiPath Studio - Final Slides.pdfUiPath Studio Session 2 - The Fundamentals of UiPath Studio - Final Slides.pdf
UiPath Studio Session 2 - The Fundamentals of UiPath Studio - Final Slides.pdf
 
Refactoring: Improving the design of existing code
Refactoring: Improving the design of existing codeRefactoring: Improving the design of existing code
Refactoring: Improving the design of existing code
 
Apache Calcite: One Frontend to Rule Them All
Apache Calcite: One Frontend to Rule Them AllApache Calcite: One Frontend to Rule Them All
Apache Calcite: One Frontend to Rule Them All
 
Important Concepts for Machine Learning
Important Concepts for Machine LearningImportant Concepts for Machine Learning
Important Concepts for Machine Learning
 
Transaction Management, Recovery and Query Processing.pptx
Transaction Management, Recovery and Query Processing.pptxTransaction Management, Recovery and Query Processing.pptx
Transaction Management, Recovery and Query Processing.pptx
 
Understanding React hooks | Walkingtree Technologies
Understanding React hooks | Walkingtree TechnologiesUnderstanding React hooks | Walkingtree Technologies
Understanding React hooks | Walkingtree Technologies
 
Machine Learning.pdf
Machine Learning.pdfMachine Learning.pdf
Machine Learning.pdf
 
Ch24 efficient algorithms
Ch24 efficient algorithmsCh24 efficient algorithms
Ch24 efficient algorithms
 
An efficient use of temporal difference technique in Computer Game Learning
An efficient use of temporal difference technique in Computer Game LearningAn efficient use of temporal difference technique in Computer Game Learning
An efficient use of temporal difference technique in Computer Game Learning
 
Layout planning
Layout planningLayout planning
Layout planning
 
Concepts of predictive control
Concepts of predictive controlConcepts of predictive control
Concepts of predictive control
 
CH1.ppt
CH1.pptCH1.ppt
CH1.ppt
 
Chapter 3.Simplex Method hand out last.pdf
Chapter 3.Simplex Method hand out last.pdfChapter 3.Simplex Method hand out last.pdf
Chapter 3.Simplex Method hand out last.pdf
 
Reinforcement learning:policy gradient (part 1)
Reinforcement learning:policy gradient (part 1)Reinforcement learning:policy gradient (part 1)
Reinforcement learning:policy gradient (part 1)
 
Algorithm analysis
Algorithm analysisAlgorithm analysis
Algorithm analysis
 

Mehr von PingCAP

[Paper Reading] Efficient Query Processing with Optimistically Compressed Has...
[Paper Reading] Efficient Query Processing with Optimistically Compressed Has...[Paper Reading] Efficient Query Processing with Optimistically Compressed Has...
[Paper Reading] Efficient Query Processing with Optimistically Compressed Has...PingCAP
 
[Paper Reading]Orca: A Modular Query Optimizer Architecture for Big Data
[Paper Reading]Orca: A Modular Query Optimizer Architecture for Big Data[Paper Reading]Orca: A Modular Query Optimizer Architecture for Big Data
[Paper Reading]Orca: A Modular Query Optimizer Architecture for Big DataPingCAP
 
[Paper Reading]KVSSD: Close integration of LSM trees and flash translation la...
[Paper Reading]KVSSD: Close integration of LSM trees and flash translation la...[Paper Reading]KVSSD: Close integration of LSM trees and flash translation la...
[Paper Reading]KVSSD: Close integration of LSM trees and flash translation la...PingCAP
 
[Paper Reading]Chucky: A Succinct Cuckoo Filter for LSM-Tree
[Paper Reading]Chucky: A Succinct Cuckoo Filter for LSM-Tree[Paper Reading]Chucky: A Succinct Cuckoo Filter for LSM-Tree
[Paper Reading]Chucky: A Succinct Cuckoo Filter for LSM-TreePingCAP
 
[Paper Reading]The Bw-Tree: A B-tree for New Hardware Platforms
[Paper Reading]The Bw-Tree: A B-tree for New Hardware Platforms[Paper Reading]The Bw-Tree: A B-tree for New Hardware Platforms
[Paper Reading]The Bw-Tree: A B-tree for New Hardware PlatformsPingCAP
 
[Paper Reading] QAGen: Generating query-aware test databases
[Paper Reading] QAGen: Generating query-aware test databases[Paper Reading] QAGen: Generating query-aware test databases
[Paper Reading] QAGen: Generating query-aware test databasesPingCAP
 
[Paper Reading] Leases: An Efficient Fault-Tolerant Mechanism for Distribute...
[Paper Reading]  Leases: An Efficient Fault-Tolerant Mechanism for Distribute...[Paper Reading]  Leases: An Efficient Fault-Tolerant Mechanism for Distribute...
[Paper Reading] Leases: An Efficient Fault-Tolerant Mechanism for Distribute...PingCAP
 
[Paper reading] Interleaving with Coroutines: A Practical Approach for Robust...
[Paper reading] Interleaving with Coroutines: A Practical Approach for Robust...[Paper reading] Interleaving with Coroutines: A Practical Approach for Robust...
[Paper reading] Interleaving with Coroutines: A Practical Approach for Robust...PingCAP
 
[Paperreading] Paxos made easy (by sen han)
[Paperreading]  Paxos made easy (by sen han)[Paperreading]  Paxos made easy (by sen han)
[Paperreading] Paxos made easy (by sen han)PingCAP
 
[Paper Reading] Generalized Sub-Query Fusion for Eliminating Redundant I/O fr...
[Paper Reading] Generalized Sub-Query Fusion for Eliminating Redundant I/O fr...[Paper Reading] Generalized Sub-Query Fusion for Eliminating Redundant I/O fr...
[Paper Reading] Generalized Sub-Query Fusion for Eliminating Redundant I/O fr...PingCAP
 
[Paper Reading] Steering Query Optimizers: A Practical Take on Big Data Workl...
[Paper Reading] Steering Query Optimizers: A Practical Take on Big Data Workl...[Paper Reading] Steering Query Optimizers: A Practical Take on Big Data Workl...
[Paper Reading] Steering Query Optimizers: A Practical Take on Big Data Workl...PingCAP
 
The Dark Side Of Go -- Go runtime related problems in TiDB in production
The Dark Side Of Go -- Go runtime related problems in TiDB  in productionThe Dark Side Of Go -- Go runtime related problems in TiDB  in production
The Dark Side Of Go -- Go runtime related problems in TiDB in productionPingCAP
 
TiDB DevCon 2020 Opening Keynote
TiDB DevCon 2020 Opening Keynote TiDB DevCon 2020 Opening Keynote
TiDB DevCon 2020 Opening Keynote PingCAP
 
Finding Logic Bugs in Database Management Systems
Finding Logic Bugs in Database Management SystemsFinding Logic Bugs in Database Management Systems
Finding Logic Bugs in Database Management SystemsPingCAP
 
Chaos Practice in PingCAP
Chaos Practice in PingCAPChaos Practice in PingCAP
Chaos Practice in PingCAPPingCAP
 
TiDB at PayPay
TiDB at PayPayTiDB at PayPay
TiDB at PayPayPingCAP
 
Paper Reading: FPTree
Paper Reading: FPTreePaper Reading: FPTree
Paper Reading: FPTreePingCAP
 
Paper Reading: Smooth Scan
Paper Reading: Smooth ScanPaper Reading: Smooth Scan
Paper Reading: Smooth ScanPingCAP
 
Paper Reading: Flexible Paxos
Paper Reading: Flexible PaxosPaper Reading: Flexible Paxos
Paper Reading: Flexible PaxosPingCAP
 
Paper reading: HashKV and beyond
Paper reading: HashKV and beyondPaper reading: HashKV and beyond
Paper reading: HashKV and beyondPingCAP
 

Mehr von PingCAP (20)

[Paper Reading] Efficient Query Processing with Optimistically Compressed Has...
[Paper Reading] Efficient Query Processing with Optimistically Compressed Has...[Paper Reading] Efficient Query Processing with Optimistically Compressed Has...
[Paper Reading] Efficient Query Processing with Optimistically Compressed Has...
 
[Paper Reading]Orca: A Modular Query Optimizer Architecture for Big Data
[Paper Reading]Orca: A Modular Query Optimizer Architecture for Big Data[Paper Reading]Orca: A Modular Query Optimizer Architecture for Big Data
[Paper Reading]Orca: A Modular Query Optimizer Architecture for Big Data
 
[Paper Reading]KVSSD: Close integration of LSM trees and flash translation la...
[Paper Reading]KVSSD: Close integration of LSM trees and flash translation la...[Paper Reading]KVSSD: Close integration of LSM trees and flash translation la...
[Paper Reading]KVSSD: Close integration of LSM trees and flash translation la...
 
[Paper Reading]Chucky: A Succinct Cuckoo Filter for LSM-Tree
[Paper Reading]Chucky: A Succinct Cuckoo Filter for LSM-Tree[Paper Reading]Chucky: A Succinct Cuckoo Filter for LSM-Tree
[Paper Reading]Chucky: A Succinct Cuckoo Filter for LSM-Tree
 
[Paper Reading]The Bw-Tree: A B-tree for New Hardware Platforms
[Paper Reading]The Bw-Tree: A B-tree for New Hardware Platforms[Paper Reading]The Bw-Tree: A B-tree for New Hardware Platforms
[Paper Reading]The Bw-Tree: A B-tree for New Hardware Platforms
 
[Paper Reading] QAGen: Generating query-aware test databases
[Paper Reading] QAGen: Generating query-aware test databases[Paper Reading] QAGen: Generating query-aware test databases
[Paper Reading] QAGen: Generating query-aware test databases
 
[Paper Reading] Leases: An Efficient Fault-Tolerant Mechanism for Distribute...
[Paper Reading]  Leases: An Efficient Fault-Tolerant Mechanism for Distribute...[Paper Reading]  Leases: An Efficient Fault-Tolerant Mechanism for Distribute...
[Paper Reading] Leases: An Efficient Fault-Tolerant Mechanism for Distribute...
 
[Paper reading] Interleaving with Coroutines: A Practical Approach for Robust...
[Paper reading] Interleaving with Coroutines: A Practical Approach for Robust...[Paper reading] Interleaving with Coroutines: A Practical Approach for Robust...
[Paper reading] Interleaving with Coroutines: A Practical Approach for Robust...
 
[Paperreading] Paxos made easy (by sen han)
[Paperreading]  Paxos made easy (by sen han)[Paperreading]  Paxos made easy (by sen han)
[Paperreading] Paxos made easy (by sen han)
 
[Paper Reading] Generalized Sub-Query Fusion for Eliminating Redundant I/O fr...
[Paper Reading] Generalized Sub-Query Fusion for Eliminating Redundant I/O fr...[Paper Reading] Generalized Sub-Query Fusion for Eliminating Redundant I/O fr...
[Paper Reading] Generalized Sub-Query Fusion for Eliminating Redundant I/O fr...
 
[Paper Reading] Steering Query Optimizers: A Practical Take on Big Data Workl...
[Paper Reading] Steering Query Optimizers: A Practical Take on Big Data Workl...[Paper Reading] Steering Query Optimizers: A Practical Take on Big Data Workl...
[Paper Reading] Steering Query Optimizers: A Practical Take on Big Data Workl...
 
The Dark Side Of Go -- Go runtime related problems in TiDB in production
The Dark Side Of Go -- Go runtime related problems in TiDB  in productionThe Dark Side Of Go -- Go runtime related problems in TiDB  in production
The Dark Side Of Go -- Go runtime related problems in TiDB in production
 
TiDB DevCon 2020 Opening Keynote
TiDB DevCon 2020 Opening Keynote TiDB DevCon 2020 Opening Keynote
TiDB DevCon 2020 Opening Keynote
 
Finding Logic Bugs in Database Management Systems
Finding Logic Bugs in Database Management SystemsFinding Logic Bugs in Database Management Systems
Finding Logic Bugs in Database Management Systems
 
Chaos Practice in PingCAP
Chaos Practice in PingCAPChaos Practice in PingCAP
Chaos Practice in PingCAP
 
TiDB at PayPay
TiDB at PayPayTiDB at PayPay
TiDB at PayPay
 
Paper Reading: FPTree
Paper Reading: FPTreePaper Reading: FPTree
Paper Reading: FPTree
 
Paper Reading: Smooth Scan
Paper Reading: Smooth ScanPaper Reading: Smooth Scan
Paper Reading: Smooth Scan
 
Paper Reading: Flexible Paxos
Paper Reading: Flexible PaxosPaper Reading: Flexible Paxos
Paper Reading: Flexible Paxos
 
Paper reading: HashKV and beyond
Paper reading: HashKV and beyondPaper reading: HashKV and beyond
Paper reading: HashKV and beyond
 

Kürzlich hochgeladen

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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
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
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 

Kürzlich hochgeladen (20)

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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
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...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
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
 
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...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 

Paper reading: Cost-based Query Transformation in Oracle

  • 1. Cost-Based Query Transformation in Oracle Presented by Yuanjia Zhang
  • 2. Problem to Solve Tranditional query optimization(in 2006) consists of two phases: ● logical phase: query is rewritten based on heuristic rules. ● physical phase: best implementations are chosen based on cost estimation. Some heuristic rules in logical phase should be made in a cost-based manner. For example: ● Join Reorder ● Group-By Placement ● Subquery Unnesting ● ...
  • 3. Problem to Solve A Subquery Unnesting Example Join SubQuery Apply e1 j Join e1 jAgg
  • 4. Overview ● Transformation in Oracle ○ Heuristic Transformations ○ Cost-Based Transformations ● Cost-Based Transformation Framework ○ Overview ○ State Space Search Techniques ○ Interaction between Transformations ○ Optimization Performance ● Performance Study
  • 5. Heuristic Transformation in Oracle Subquery Unnesting Two categories of subquery unnesting: ● unnesting that generates inline views. ● unnesting that merges a subquery into its outer query. Note that dept_id in employees is a foreign key that references the primary key of departments. Join d e d e Apply
  • 6. Heuristic Transformation in Oracle Join Elimination Remove tables from a query if there are constraints on the join columns. Note that dept_id in employees is a foreign key that references the primary key of departments.
  • 7. Heuristic Transformation in Oracle Group Pruning Remove views groups not needed in the outer query blocks.
  • 8. Cost-Based Transformation in Oracle Subquery Unnesting Two categories of subquery unnesting: ● unnesting that generates inline views. ● unnesting that merges a subquery into its outer query. Join SubQuery Apply e1 j Join e1 jAgg
  • 9. Cost-Based Transformation in Oracle Group-By and Distinct View Merging Merge view contains group-by or distinct into its outer query block. Join e1 jAgg e2 Join e1 j Agg e2
  • 10. Cost-Based Transformation in Oracle Join Predicate Pushdown Push join predicates into a view. Join e1 jAgg e1 j NestJoin/Apply l
  • 11. Cost-Based Transformation in Oracle Join Factorization Pull common join tables up to the outer UNION ALL query block. Union l Join Join de jd el Union Join Join d e je l
  • 12. Cost-Based Transformation in Oracle Expensive Predicate Pullup Pull expensive predicates up from the originating view to outer query block. A predicate is considered expensive if it contains ● procedural language, ● user-defined operators, ● subqueries. This transformation is only considered when rownum(limit) predicate is specified.
  • 13. Cost-Based Transformation Framework PhysicalOptimization Component is used to: ● estimate query tree cost, ● generate the final physical execution plan. The order of applying transformations matters, so... common sub-expression factorization, SPJ view merging, join elimination, subquery unnesting, group-by (distinct) view merging, group pruning, predicate move around, set operator into join conversion, group-by placement, predicate pullup, join factorization, disjunction into union-all expansion, star transformation, and join predicate pushdown
  • 14. State Space Search Techniques Definition of state in search space We have a query consists of N objects(e.g., tables, join edges, predicats, etc.), and we have M transformatins that can apply on the N objects, then the state is represented by an M*N bit matrix and there are 2^(M*N) states totally. If we only have one transformation, expensive predicate pullup, then the SQL below have four states: ● [[0, 0]], ● [[0, 1]], ● [[1, 0]], ● [[1, 1]].
  • 15. State Space Search Techniques How to search in state space Four different techniques(only consider one transformation): ● Exhaustive: all 2^N states for N objects are considered. ● Two-pass: only consider 2 states, [[0, 0, ...0]] and [[1, 1, ...1]]. ● Linear: a dynamic programming approach that suppose different objects are independent; N+1 states are considered. ● Iterative: a. start from an initial state and look for a local minimum state. b. choose a different initial state and repeat step a until ■ no more new states to be found, or ■ some terminatin condition has been reached. c. N+1~2^N states are considered.
  • 16. Interaction between Transformations Interleaving When two (or more) cost-based transformations apply on the same object such that one transformation becomes applicable only after the other has been applied, then these transformations must be interleaved in order for the optimizer to determine the optimal plan. We begin at S0, and we can apply T1 to S1 and we can apply T2, T3 to S2, S3; If we don’t interleave T3 after T2, we can’t get to S3 and the best state Sfinal on the right.
  • 17. Interaction between Transformations Juxtaposition When two or more cost-based transformations apply on the same object in a way that precludes their sequential application, they must be applied one by one in order for the optimizer to determine the most optimal plan. This comparison of two or more cost-based transformations is called juxtaposition. We begin at S0, and we can apply T1 to S1 or T2 to S2 but T1 < T2 in sequential order and we know if we get to S1, we can’t get to S2 probably. If we don’t consider T2 when we apply T1, we can’t get to S2 and the best state Sfinal on the right.
  • 18. Interaction between Transformations Juxtaposition An example: view merging and join predicate push down must be juxtaposed with each other. Join e1 jAgge1 jAgg NestJoin/Apply Join e1 j Agg e2 view mergingJPPD
  • 19. Optimization Performance Reuse of Query Sub-Tree Cost Annotations We have a query with two subquery and a transformation which can be applied on subquery. Then we have four states: Cost information of Qs1, Qs2, T(Qs1), T(Qs2) can be used.
  • 20. Performance Study Dataset ● 14000 tables representing HR, Financial, Order Entry, CRM, Supply Chain… ● 241000 queries ○ the average number of tables in a query is 8, ○ most of the queries are of simple Sel/Proj/Join type, ○ 8% of these queries have subqueries, GROUP-BY, DISTINCT or UNION ALL. Result ● 5910 execution plans changed. ● the total run time improved by 20% on average. ● 18% affected queries degraded by 40%. ● the top 5% of longest running queries improved 27%. ● optimization time increased by only 40%.
  • 21. Any Questions ? 关注 PingCAP 官方微信 了解更多技术干货 Thank You!