Chapter 2 Query Processing & Optmzn
Chapter 2 Query Processing & Optmzn
Examples:
(OP1): SSN='123456789' (EMPLOYEE)
(OP2): DNUMBER>5(DEPARTMENT)
(OP3): DNO=5(EMPLOYEE)
(OP4): DNO=5 AND SALARY>30000 AND SEX=F(EMPLOYEE)
(OP5): ESSN=123456789 AND PNO=10(WORKS_ON)
Index
Example
SELECT MAX (SALARY)
FROM EMPLOYEE;
be accounted for
With GROUP BY: the aggregate operator must be applied separately
to each group of tuples.
Use sorting or hashing on the group attributes to partition the file
tables}
TEMP1FNAME,DNAME(EMPLOYEE DNO=DNUMBER DEPARTMENT)
{Find the EMPLOYEEs that do not appear in the JOIN}
TEMP2 FNAME (EMPLOYEE) - FNAME (Temp1)
{Pad each tuple in TEMP2 with a null DNAME field}
SQL query:
Q2: SELECT P.NUMBER,P.DNUM,E.LNAME,
E.ADDRESS, E.BDATE
FROM PROJECT AS P,DEPARTMENT
AS D, EMPLOYEE AS E
WHERE P.DNUM=D.DNUMBER AND
D.MGRSSN=E.SSN AND
P.PLOCATION=‘STAFFORD’;
Other transformations
Issues
Cost function
Number of execution strategies to be considered
Left-deep tree:
A binary tree where the right child of each non-leaf node is
always a base relation.
Amenable to pipelining
Could utilize any access paths on the base relation (the right
child) when executing the join.
stated that no employee can earn more than his or her direct
supervisor. If the semantic query optimizer checks for the
existence of this constraint, it need not execute the query at all
because it knows that the result of the query will be empty.
Techniques known as theorem proving can be used for this
purpose.