COMP9315 21T1 ♢ Query Processing ♢ [0/6]
COMP9315 21T1 ♢ Query Processing ♢ [1/6]
❖ Query Processing (cont) | |
A query in SQL:
- states what kind of answers are required (declarative)
- does not say how they should be computed (procedural)
A
query evaluator/processor :
- takes declarative description of query
(in SQL)
- parses query to internal representation
(relational algebra)
- determines plan for answering query
(expressed as DBMS ops)
- executes method via DBMS engine
(to produce result tuples)
Some DBMSs can save query plans for later re-use.
COMP9315 21T1 ♢ Query Processing ♢ [2/6]
❖ Query Processing (cont) | |
Internals of the query evaluation "black-box":
COMP9315 21T1 ♢ Query Processing ♢ [3/6]
❖ Query Processing (cont) | |
DBMSs provide several "flavours" of each RA operation.
For example:
Similarly, π and ⨝ have versions to match
specific query types.
COMP9315 21T1 ♢ Query Processing ♢ [4/6]
❖ Query Processing (cont) | |
We call these specialised version of RA operations RelOps.
One major task of the query processor:
- given a RA expression to be evaluated
- find a combination of RelOps to do this efficiently
Requires the query translator/optimiser to consider
- information about relations (e.g. sizes, primary keys, ...)
- information about operations (e.g. selection reduces size)
RelOps are realised at execution time
- as a collection of inter-communicating nodes
- communicating either via pipelines or temporary relations
COMP9315 21T1 ♢ Query Processing ♢ [5/6]
Relational algebra expression of SQL query
- intermediate query representation
- logical query plan
Execution plan as collection of RelOps
- query evaluation plan
- query execution plan
- physical query plan
Representation of RA operators and expressions
- σ = Select = Sel,
π = Project = Proj
- R ⨝ S = R Join S = Join(R,S),
∧ = &, ∨ = |
COMP9315 21T1 ♢ Query Processing ♢ [6/6]
Produced: 5 Apr 2021