SlideShare ist ein Scribd-Unternehmen logo
1 von 10
 Query Optimization
 Why Query Optimization?
 Join Size Estimation?
 Estimation of Number of Distinct Values.
 Query optimization is the process of selecting
the most efficient query-evaluation plan from
among the many strategies usually possible
for processing a given query, especially if the
query is complex.
 In simple scenes the query optimizer come
up with query-evaluation plan that computes
the same result as a given expression, but it
is a least costly way of generating result.
 Faster processing of a query.
 Lesser cost per query.
 High performance of the system.
 Lesser stress on the database.
 Efficient use of database engine.
 Lesser memory is consumed.
 Catalog information:-
 nr : number of tuples in a relation r.
 br : number of blocks containing tuples of r.
 sr : size of a tuple of r.
 fr : blocking factor of r — i.e., the number of tuples of r that fit into one block.
 V(A, r): number of distinct values that appear in r for attribute A; same as the size
of A(r).
 SC(A, r): selection cardinality of attribute A of relation r; average number of
records that satisfy equality on A.
 If tuples of r are stored together physically in a file, then:











rf
rn
rb
 The Cartesian product r x s contains nr .ns tuples; each
tuple occupies sr + ss bytes.
 If R  S = , then r s is the same as r x s. i.e. the
relation has no attributes in common.
 If R  S is a key for R, then a tuple of s will join with at
most one tuple from r
◦ therefore, the number of tuples in r s is no greater than the
number of tuples in s.
 If R  S forms a foreign key in S referencing R, then the
number of tuples in r s is exactly the same as the
number of tuples in s.
 In the example query depositor customer, customer-
name in depositor is a foreign key of customer
◦ hence, the result has exactly ndepositor tuples, which is 5000
 If R  S = {A} is not a key for R or S.
If we assume that every tuple t in R produces
tuples in R S, the number of tuples in R S is
estimated to be:
If the reverse is true, the estimate obtained will
be:
The lower of these two estimates is probably the
more accurate one.
),( sAV
nn sr 
),( rAV
nn sr 
Selections:  (r)
 If  forces A to take a specified value: V(A, (r)) = 1.
 e.g., A = 3
 If  forces A to take on one of a specified set of
values:
V(A, (r)) = number of specified values.
 (e.g., (A = 1 V A = 3 V A = 4 )),
 If the selection condition  is of the form A op r
estimated V(A, (r)) = V(A.r) * s
 where s is the selectivity of the selection.
 In all the other cases: use approximate estimate of
min(V(A,r), n (r) )
◦ More accurate estimate can be got using probability theory,
but this one works fine generally
Joins: r s
 If all attributes in A are from r
estimated V(A, r s) = min (V(A,r), n r s)
 If A contains attributes A1 from r and A2
from s, then estimated V(A, r s) =
min(V(A1,r)*V(A2 – A1,s), V(A1 –
A2,r)*V(A2,s), nr s)
◦ More accurate estimate can be got using
probability theory, but this one works fine generally
THANKYOU…!!!

Weitere ähnliche Inhalte

Was ist angesagt?

Query processing-and-optimization
Query processing-and-optimizationQuery processing-and-optimization
Query processing-and-optimizationWBUTTUTORIALS
 
8 query processing and optimization
8 query processing and optimization8 query processing and optimization
8 query processing and optimizationKumar
 
Query-porcessing-& Query optimization
Query-porcessing-& Query optimizationQuery-porcessing-& Query optimization
Query-porcessing-& Query optimizationSaranya Natarajan
 
Query optimization
Query optimizationQuery optimization
Query optimizationdixitdavey
 
Cost estimation for Query Optimization
Cost estimation for Query OptimizationCost estimation for Query Optimization
Cost estimation for Query OptimizationRavinder Kamboj
 
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...Beat Signer
 
13. Query Processing in DBMS
13. Query Processing in DBMS13. Query Processing in DBMS
13. Query Processing in DBMSkoolkampus
 
INTRODUCTION TO ALGORITHMS Third Edition
INTRODUCTION TO ALGORITHMS Third EditionINTRODUCTION TO ALGORITHMS Third Edition
INTRODUCTION TO ALGORITHMS Third EditionPHI Learning Pvt. Ltd.
 
Distributed Query Processing
Distributed Query ProcessingDistributed Query Processing
Distributed Query ProcessingMythili Kannan
 
Adversarial search
Adversarial searchAdversarial search
Adversarial searchNilu Desai
 

Was ist angesagt? (20)

Query processing-and-optimization
Query processing-and-optimizationQuery processing-and-optimization
Query processing-and-optimization
 
8 query processing and optimization
8 query processing and optimization8 query processing and optimization
8 query processing and optimization
 
Query-porcessing-& Query optimization
Query-porcessing-& Query optimizationQuery-porcessing-& Query optimization
Query-porcessing-& Query optimization
 
Query optimization
Query optimizationQuery optimization
Query optimization
 
Query trees
Query treesQuery trees
Query trees
 
Cost estimation for Query Optimization
Cost estimation for Query OptimizationCost estimation for Query Optimization
Cost estimation for Query Optimization
 
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
Query Processing and Optimisation - Lecture 10 - Introduction to Databases (1...
 
13. Query Processing in DBMS
13. Query Processing in DBMS13. Query Processing in DBMS
13. Query Processing in DBMS
 
INTRODUCTION TO ALGORITHMS Third Edition
INTRODUCTION TO ALGORITHMS Third EditionINTRODUCTION TO ALGORITHMS Third Edition
INTRODUCTION TO ALGORITHMS Third Edition
 
Adbms lab manual
Adbms lab manualAdbms lab manual
Adbms lab manual
 
Map reduce prashant
Map reduce prashantMap reduce prashant
Map reduce prashant
 
Chapter15
Chapter15Chapter15
Chapter15
 
Advanced sql
Advanced sqlAdvanced sql
Advanced sql
 
Query optimization
Query optimizationQuery optimization
Query optimization
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Distributed Query Processing
Distributed Query ProcessingDistributed Query Processing
Distributed Query Processing
 
Divide and Conquer
Divide and ConquerDivide and Conquer
Divide and Conquer
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
Measures of query cost
Measures of query costMeasures of query cost
Measures of query cost
 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
 

Andere mochten auch

Database , 8 Query Optimization
Database , 8 Query OptimizationDatabase , 8 Query Optimization
Database , 8 Query OptimizationAli Usman
 
Quarry Optimization Module
Quarry Optimization ModuleQuarry Optimization Module
Quarry Optimization Moduledeeptec
 
CEMEX_SeniorDesignPosterUpdate4.21.3.pptx
CEMEX_SeniorDesignPosterUpdate4.21.3.pptxCEMEX_SeniorDesignPosterUpdate4.21.3.pptx
CEMEX_SeniorDesignPosterUpdate4.21.3.pptxArda Onkol
 
Kitaly Venance D. - Blast Design Optimization to Improve Material Fragmentati...
Kitaly Venance D. - Blast Design Optimization to Improve Material Fragmentati...Kitaly Venance D. - Blast Design Optimization to Improve Material Fragmentati...
Kitaly Venance D. - Blast Design Optimization to Improve Material Fragmentati...Venance Kitaly
 
Overview of query evaluation
Overview of query evaluationOverview of query evaluation
Overview of query evaluationavniS
 
SQL Joins and Query Optimization
SQL Joins and Query OptimizationSQL Joins and Query Optimization
SQL Joins and Query OptimizationBrian Gallagher
 
Query processing and optimization (updated)
Query processing and optimization (updated)Query processing and optimization (updated)
Query processing and optimization (updated)Ravinder Kamboj
 
Data warehouse architecture
Data warehouse architectureData warehouse architecture
Data warehouse architecturepcherukumalla
 
Introduction to Data Warehousing
Introduction to Data WarehousingIntroduction to Data Warehousing
Introduction to Data WarehousingJason S
 
Components of a Data-Warehouse
Components of a Data-WarehouseComponents of a Data-Warehouse
Components of a Data-WarehouseAbdul Aslam
 
Data Warehousing and Data Mining
Data Warehousing and Data MiningData Warehousing and Data Mining
Data Warehousing and Data Miningidnats
 

Andere mochten auch (14)

Database , 8 Query Optimization
Database , 8 Query OptimizationDatabase , 8 Query Optimization
Database , 8 Query Optimization
 
Quarry Optimization Module
Quarry Optimization ModuleQuarry Optimization Module
Quarry Optimization Module
 
CEMEX_SeniorDesignPosterUpdate4.21.3.pptx
CEMEX_SeniorDesignPosterUpdate4.21.3.pptxCEMEX_SeniorDesignPosterUpdate4.21.3.pptx
CEMEX_SeniorDesignPosterUpdate4.21.3.pptx
 
Kitaly Venance D. - Blast Design Optimization to Improve Material Fragmentati...
Kitaly Venance D. - Blast Design Optimization to Improve Material Fragmentati...Kitaly Venance D. - Blast Design Optimization to Improve Material Fragmentati...
Kitaly Venance D. - Blast Design Optimization to Improve Material Fragmentati...
 
Overview of query evaluation
Overview of query evaluationOverview of query evaluation
Overview of query evaluation
 
Query processing
Query processingQuery processing
Query processing
 
SQL Joins and Query Optimization
SQL Joins and Query OptimizationSQL Joins and Query Optimization
SQL Joins and Query Optimization
 
Query processing and optimization (updated)
Query processing and optimization (updated)Query processing and optimization (updated)
Query processing and optimization (updated)
 
Data Warehouse 101
Data Warehouse 101Data Warehouse 101
Data Warehouse 101
 
DATA WAREHOUSING
DATA WAREHOUSINGDATA WAREHOUSING
DATA WAREHOUSING
 
Data warehouse architecture
Data warehouse architectureData warehouse architecture
Data warehouse architecture
 
Introduction to Data Warehousing
Introduction to Data WarehousingIntroduction to Data Warehousing
Introduction to Data Warehousing
 
Components of a Data-Warehouse
Components of a Data-WarehouseComponents of a Data-Warehouse
Components of a Data-Warehouse
 
Data Warehousing and Data Mining
Data Warehousing and Data MiningData Warehousing and Data Mining
Data Warehousing and Data Mining
 

Ähnlich wie Query Optimization

2 data structure in R
2 data structure in R2 data structure in R
2 data structure in Rnaroranisha
 
MODULE 5- EDA.pptx
MODULE 5- EDA.pptxMODULE 5- EDA.pptx
MODULE 5- EDA.pptxnikshaikh786
 
Multinomial Model Simulations
Multinomial Model SimulationsMultinomial Model Simulations
Multinomial Model Simulationstim_hare
 
relational model.pptx
relational model.pptxrelational model.pptx
relational model.pptxThangamaniR3
 
Module 3 - Regular Expressions, Dictionaries.pdf
Module 3 - Regular  Expressions,  Dictionaries.pdfModule 3 - Regular  Expressions,  Dictionaries.pdf
Module 3 - Regular Expressions, Dictionaries.pdfGaneshRaghu4
 
relational model in Database Management.ppt.ppt
relational model in Database Management.ppt.pptrelational model in Database Management.ppt.ppt
relational model in Database Management.ppt.pptRoshni814224
 
Relational algebra operations
Relational algebra operationsRelational algebra operations
Relational algebra operationsSanthiNivas
 
Data Representation of Strings
Data Representation of StringsData Representation of Strings
Data Representation of StringsProf Ansari
 
4. SQL in DBMS
4. SQL in DBMS4. SQL in DBMS
4. SQL in DBMSkoolkampus
 
Relation model part 1
Relation model part 1Relation model part 1
Relation model part 1Siti Ismail
 
Query optimization in database
Query optimization in databaseQuery optimization in database
Query optimization in databaseRakesh Kumar
 

Ähnlich wie Query Optimization (20)

Ch14
Ch14Ch14
Ch14
 
1. linear model, inference, prediction
1. linear model, inference, prediction1. linear model, inference, prediction
1. linear model, inference, prediction
 
2 data structure in R
2 data structure in R2 data structure in R
2 data structure in R
 
relational algebra
relational algebrarelational algebra
relational algebra
 
MODULE 5- EDA.pptx
MODULE 5- EDA.pptxMODULE 5- EDA.pptx
MODULE 5- EDA.pptx
 
Pertemuan 5_Relation Matriks_01 (17)
Pertemuan 5_Relation Matriks_01 (17)Pertemuan 5_Relation Matriks_01 (17)
Pertemuan 5_Relation Matriks_01 (17)
 
Multinomial Model Simulations
Multinomial Model SimulationsMultinomial Model Simulations
Multinomial Model Simulations
 
relational model.pptx
relational model.pptxrelational model.pptx
relational model.pptx
 
Cis435 week03
Cis435 week03Cis435 week03
Cis435 week03
 
Module 3 - Regular Expressions, Dictionaries.pdf
Module 3 - Regular  Expressions,  Dictionaries.pdfModule 3 - Regular  Expressions,  Dictionaries.pdf
Module 3 - Regular Expressions, Dictionaries.pdf
 
Ch2
Ch2Ch2
Ch2
 
relational model in Database Management.ppt.ppt
relational model in Database Management.ppt.pptrelational model in Database Management.ppt.ppt
relational model in Database Management.ppt.ppt
 
Relational algebra operations
Relational algebra operationsRelational algebra operations
Relational algebra operations
 
Data Representation of Strings
Data Representation of StringsData Representation of Strings
Data Representation of Strings
 
4. SQL in DBMS
4. SQL in DBMS4. SQL in DBMS
4. SQL in DBMS
 
Eryk_Kulikowski_a3
Eryk_Kulikowski_a3Eryk_Kulikowski_a3
Eryk_Kulikowski_a3
 
Programming Exam Help
Programming Exam Help Programming Exam Help
Programming Exam Help
 
Relation model part 1
Relation model part 1Relation model part 1
Relation model part 1
 
Query optimization in database
Query optimization in databaseQuery optimization in database
Query optimization in database
 
Lllll
LllllLllll
Lllll
 

Kürzlich hochgeladen

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 

Kürzlich hochgeladen (20)

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 

Query Optimization

  • 1.
  • 2.  Query Optimization  Why Query Optimization?  Join Size Estimation?  Estimation of Number of Distinct Values.
  • 3.  Query optimization is the process of selecting the most efficient query-evaluation plan from among the many strategies usually possible for processing a given query, especially if the query is complex.  In simple scenes the query optimizer come up with query-evaluation plan that computes the same result as a given expression, but it is a least costly way of generating result.
  • 4.  Faster processing of a query.  Lesser cost per query.  High performance of the system.  Lesser stress on the database.  Efficient use of database engine.  Lesser memory is consumed.
  • 5.  Catalog information:-  nr : number of tuples in a relation r.  br : number of blocks containing tuples of r.  sr : size of a tuple of r.  fr : blocking factor of r — i.e., the number of tuples of r that fit into one block.  V(A, r): number of distinct values that appear in r for attribute A; same as the size of A(r).  SC(A, r): selection cardinality of attribute A of relation r; average number of records that satisfy equality on A.  If tuples of r are stored together physically in a file, then:            rf rn rb
  • 6.  The Cartesian product r x s contains nr .ns tuples; each tuple occupies sr + ss bytes.  If R  S = , then r s is the same as r x s. i.e. the relation has no attributes in common.  If R  S is a key for R, then a tuple of s will join with at most one tuple from r ◦ therefore, the number of tuples in r s is no greater than the number of tuples in s.  If R  S forms a foreign key in S referencing R, then the number of tuples in r s is exactly the same as the number of tuples in s.  In the example query depositor customer, customer- name in depositor is a foreign key of customer ◦ hence, the result has exactly ndepositor tuples, which is 5000
  • 7.  If R  S = {A} is not a key for R or S. If we assume that every tuple t in R produces tuples in R S, the number of tuples in R S is estimated to be: If the reverse is true, the estimate obtained will be: The lower of these two estimates is probably the more accurate one. ),( sAV nn sr  ),( rAV nn sr 
  • 8. Selections:  (r)  If  forces A to take a specified value: V(A, (r)) = 1.  e.g., A = 3  If  forces A to take on one of a specified set of values: V(A, (r)) = number of specified values.  (e.g., (A = 1 V A = 3 V A = 4 )),  If the selection condition  is of the form A op r estimated V(A, (r)) = V(A.r) * s  where s is the selectivity of the selection.  In all the other cases: use approximate estimate of min(V(A,r), n (r) ) ◦ More accurate estimate can be got using probability theory, but this one works fine generally
  • 9. Joins: r s  If all attributes in A are from r estimated V(A, r s) = min (V(A,r), n r s)  If A contains attributes A1 from r and A2 from s, then estimated V(A, r s) = min(V(A1,r)*V(A2 – A1,s), V(A1 – A2,r)*V(A2,s), nr s) ◦ More accurate estimate can be got using probability theory, but this one works fine generally