Query Manager

The Query Manager takes a query tree from the command parser and generates the best access plan to be executed for retrieving the records tha satisfy the query. An access plan is a tree of physical operators that implement algorithms to execute the relational algebra operators.

The current version of the optimizer, implemented by Leonardo Candela using the OPT++ approach, allows to choose:

The default choices are left-deep access plans, and greedy optimization using all the physical operators.

The representation of a query plan in the form of a tree was implemented by Luca Saiu.

Each physical operator is an iterator with metods open, next, isDone, reset and close implemented using the operators on storage structures and the access methods provided by the storage engine.

Physical operators for access plans.

Catalog tables.

Access plans examples

SELECT DISTINCT Cognome
FROM   Impiegati
WHERE  AnnoNascita > 1970;          Access Plan

SELECT   Nome, MAX(AnnoNascita)
FROM     Impiegati
WHERE    AnnoNascita > 1970
GROUP BY Nome
HAVING   COUNT(*) = 1;              Access Plan

SELECT  Nome
FROM    Impiegati
WHERE   AnnoNascita < 1975
   UNION
SELECT  Nome
FROM    Impiegati
WHERE   AnnoNascita > 1980;         Access Plan

SELECT   Cognome, d.Nome
FROM     Impiegati i, Dipartimenti d
WHERE    i.Dipartimento = d.Numero
  AND    d.Citta  = 'PI'
  AND    i.Codice > 13
ORDER BY Cognome desc;              Access Plan

For more examples see (in Italian)

 

JRS Architecture
JRS Home Page