Query Optimization Course
- Run
make
to compile the source code. - Run
make db
to create a sample database inside thedata
directory.
The query execution logic can be found in src
; test it using e.g.
bin/query data/uni "SELECT v.titel
FROM studenten s, hoeren h, vorlesungen v
WHERE s.matrnr=h.matrnr
AND h.vorlnr=v.vorlnr
AND s.name='Carnap'"
This should give the following output:
Ethik
Wissenschaftstheorie
Bioethik
Der Wiener Kreis
Basically, query graph and join tree will be generated and shown when using EXPLAIN
instead of SELECT
in SQL queries.
To generate an image file, the circo
and dot
executables provided by graphviz are needed. Also ImageMagick's display
command is required.
Test it using e.g.
bin/query data/uni "EXPLAIN * FROM studenten s, hoeren h, vorlesungen v WHERE s.matrnr=h.matrnr AND v.vorlnr=h.vorlnr"
The source code is located in exercises/ex01
. Execute the code using bin/ex01-query1
and
bin/ex01-query2
.
- Execute
make tpch-db
to fetch TPC-H data (7zip is required) and create a database. - Run
bin/ex05-query.sh
to execute the exercise query. It runs the query usingEXPLAIN
, so query graph and join tree will be shown.
To generate Dyck words, execute e.g. bin/dyck 7 56
. This will generate the Dyck word from the exercise session 7 example, "(((())())(()))".