Docsity

Database Notes - Database Systems | EEL 4852C, Study notes of Deductive Database Systems

Toggle sidebar
bg1
November 13, 2008
Database Notes
Query Processing Workflow Inside DBMS
Query Optimizer
Query (SQL) R.A. Tree
One Many
Many Query Plans
(user side) One
Query Results Execution Plan
Query 1:
SELECT E.name Π
FROM Employee, Works_On
WHERE E.ssn = W_O.Essn (1)
AND E.b_date < ‘11/13/78’ (2) σ 1 x 2 x 3
AND W_O.Pno = 100; (3)
R.A. = Π E.name (σ __ (E x W_O)) x
Π
E W_O
Π
σ b_date < __
σ Pno = 100 σ b_date < __
W_O E σ Pno = 100 E
W_O
*different ways to describe one query with relational algebra
By using a complete set of Equivalence Rules (ER), we can enumerate all R.A. Trees.
Query
Parser
Plan
Generator
Cost
Model
Query
Executer
pf3

Partial preview of the text

Download Database Notes - Database Systems | EEL 4852C and more Study notes Deductive Database Systems in PDF only on Docsity!

November 13, 2008 Database Notes

Query Processing Workflow Inside DBMS Query Optimizer Query (SQL) R.A. Tree

One Many

Many Query Plans

(user side) One

Query Results Execution Plan

Query 1: SELECT E.name Π FROM Employee, Works_On WHERE E.ssn = W_O.Essn (1) AND E.b_date < ‘11/13/78’ (2) σ 1 x 2 x 3 AND W_O.Pno = 100; (3)

R.A. = Π E.name (σ __ (E x W_O)) x

Π E W_O

σ b_date < __ σ Pno = 100 σ b_date < __

W_O E σ Pno = 100 E

W_O

*different ways to describe one query with relational algebra

By using a complete set of Equivalence Rules (ER), we can enumerate all R.A. Trees.

Query Parser

Plan Generator

Cost Model

Query Executer

Query Plan: a Q.P. is a R.A. Tree augmented with algorithms to accomplish R.A. operations.

3 x 3 x 3 = 27 different 3 plans based on the tree (alg. 6)

(alg. 1) σ Pno = 100 σ b_date < __ (alg. 3)

W_O E

*Each tree can have a great number of plans using algorithms

Algorithms for processing R.A. Operators

  1. Selection (σ) a. Option 1: Table Scan b. Option 2: Index-based Scan

Complex Selections – Selection with conditions on more than one attribute The usage of indexes has profound effects on complex selection in terms of performance. Some Rules:

  1. Tree-Based Index on , only benefits selections on a prefix of e.g. , ,
  2. Hash-Based Index on whatever set of attributes is only good for exact matches ex: Index (salary) -- Hash Hash  Q1: __ WHERE Salary = 55k; Tree-Based  Q2: __ WHERE Salary < 56k AND Salary > 30k;

*Only Query 1 can be used w/ the hash index (hash does not work on ranged functions)

  1. Project (Π) Table Scan! (and then pick the columns you want) Ask: Do we need duplicates eliminated? What if the answer is yes? 1. Sorting-based 2. Hashing-based
  2. Join( ) Product of A and B with selection condition (equalities) σ __ (A x B) Equality Join