+ All Categories
Home > Documents > Fan Qi [email protected] Database Lab 1, com1 #01-08 CS3223 Tutorial 8.

Fan Qi [email protected] Database Lab 1, com1 #01-08 CS3223 Tutorial 8.

Date post: 17-Dec-2015
Category:
Upload: ernest-hoover
View: 219 times
Download: 1 times
Share this document with a friend
Popular Tags:

of 19

Click here to load reader

Transcript
  • Slide 1
  • Fan Qi [email protected] Database Lab 1, com1 #01-08 CS3223 Tutorial 8
  • Slide 2
  • Query Optimization Similar to other optimization Optimize by search Two main factor: Search Space: how many candidates Evaluation function : how to judge which candidate is good Search Space Query Plan
  • Slide 3
  • Query Optimization Search Space Enumeration Relational Algebra Equivalences Query rewrite: View rewrite Semantic rewrite Subquery flatterning
  • Slide 4
  • Query Optimization Evaluation function: A.K.A cost model Evaluate query plan based on statistical information Assumptions: Independence, Uniform distribution, inclusion assumption Reduction Factor Selectivity Histogram: Equiwidth Equidepth Number of Rows Per Column Distinct Value Per Column Value Distribution Combined Column Value Distribution Available Index... Number of Rows Per Column Distinct Value Per Column Value Distribution Combined Column Value Distribution Available Index...
  • Slide 5
  • Query Optimization What if we know both ? Dynamic programming optimization Optimal Substructure C D A B If Q is optimal, all its subquery are optimal
  • Slide 6
  • Question 1 (A)
  • Slide 7
  • Question 1 (B) 137 180 97
  • Slide 8
  • Question 1 (C) A Implies B U A A
  • Slide 9
  • Question 2 Equiwidth histogram with 3 buckets 9 distinct value Each bucket has 3 distinct values
  • Slide 10
  • Question 3 Access Methods: Table Scan Clustered B+ tree (age, sal) Hash Index on (eid) Unclustered B+ tree (sal) Hash Index on (age)
  • Slide 11
  • Question 3 (a) Access Methods: Table Scan Clustered B+ tree (age, sal) Hash Index on (eid) Unclustered B+ tree (sal) Hash Index on (age) 20,000 Not Applicable
  • Slide 12
  • Question 3 (b) Access Methods: Table Scan Clustered B+ tree (age, sal) Hash Index on (eid) Unclustered B+ tree (sal) Hash Index on (age) Not Applicable 2,000 + 20,000
  • Slide 13
  • Question 3 (c) Access Methods: Table Scan Clustered B+ tree (age, sal) Hash Index on (eid) Unclustered B+ tree (sal) Hash Index on (age) Not Applicable
  • Slide 14
  • Question 3 (d) Access Methods: Table Scan Clustered B+ tree (age, sal) Hash Index on (eid) Unclustered B+ tree (sal) Hash Index on (age) Not Applicable 2,000 + 1 Not Applicable
  • Slide 15
  • Question 3 (e) Access Methods: Table Scan Clustered B+ tree (age, sal) Hash Index on (eid) Unclustered B+ tree (sal) Hash Index on (age) Not Applicable
  • Slide 16
  • Question 3 (f) Access Methods: Table Scan Clustered B+ tree (age, sal) Hash Index on (eid) Unclustered B+ tree (sal) Hash Index on (age) Not Applicable 2,000 + 20,000
  • Slide 17
  • Question 3 (g) Access Methods: Table Scan Clustered B+ tree (age, sal) Hash Index on (eid) Unclustered B+ tree (sal) Hash Index on (age) Not Applicable
  • Slide 18
  • Question 3 (h) Access Methods: Table Scan Clustered B+ tree (age, sal) Hash Index on (eid) Unclustered B+ tree (sal) Hash Index on (age) Not Applicable
  • Slide 19

Recommended