Query Optimization
Query Optimization
General Information
Module No.: IE 630 Type: Lecture Lecturer: Prof. Dr. Guido Moerkotte Interval: Spring semester Credit: 6 ECTS (4SWS) Time and place: Time: Tues. 13:45–15:15, B 6 A 303
Place: Via Zoom
See portalFirst time: 15.02.2022 Query optimization is a function of many relational database management systems. The query optimizer attempts to determine the most efficient way to execute a given query by considering the possible query plans.
A query is a request for information from a database. It can be as simple as “finding the address of a person with SS# 123-45-6789,” or more complex like “finding the average salary of all the employed married men in California between the ages 30 to 39, that earn less than their wives.”
Queries results are generated by accessing relevant database data and manipulating it in a way that yields the requested information. Since database structures are complex, in most cases, and especially for not-very-simple queries, the needed data for a query can be collected from a database by accessing it in different ways, through different data-structures, and in different orders. Each different way typically requires different processing time. Processing times of the same query may have large variance, from a fraction of a second to hours, depending on the way selected.
The purpose of query optimization, which is an automated process, is to find the way to process a given query in minimum time. The large possible variance in time justifies performing query optimization, though finding the exact optimal way to execute a query, among all possibilities, is typically very complex, time consuming by itself, may be too costly, and often practically impossible. Thus query optimization typically tries to approximate the optimum by comparing several common-sense alternatives to provide in a reasonable time a “good enough” plan which typically does not deviate much from the best possible result.In this lecture we discuss join ordering, usage of index structures, subquery unnesting, and basic formulas for cost estimation.
Prerequisites
Knowledge in Database Systems and Algorithms.
Materials
Exercise Sessions
Lecturer: Magnus Müller Time and place: Usually: Wed. 13:45–15:15, B6 A 203 First time: 16.02.2022 NOTE:
– If you're interested in C++ programming, I highly recommend attending the first exercise sessions in DBSII.
– If you are interested in Go programming, this 1h video and this tutorial might be a good entry point.
– Summary pdf from last year: here
– For a good discussion on IKKBZ, see https://db.in.tum.de/teaching/ws1819/queryopt/exercises/session5.pdf (starting at pdf-page 14). See here for another example run pdf.Excercise Sheets
Solutions
- Solution-1-Sheet ( PDF , 149 KB )
- Solution-1-Code ( GO , 2 KB )
- Solution-2-Sheet ( PDF , 119 KB )
- Solution-2-Code ( GO , 4 KB )
- Solution-3-Sheet ( PDF , 150 KB )
- Solution-3-Code ( ZIP , 4 KB )
- Solution-4-Sheet ( PDF , 123 KB )
- Solution-4-Code ( GO , 1 KB )
- Solution-5-Sheet ( PDF , 197 KB )
- Solution-5-Code ( ZIP , 35 KB )
- Solution-6-Sheet ( PDF , 116 KB )
- Solution-6-Code ( ZIP , 34 KB )
- Solution-7-Sheet ( PDF , 130 KB )
- Solution-7-Code ( ZIP , 34 KB )
- Solution-8-Sheet ( PDF , 177 KB )
- Solution-8-Code ( ZIP , 36 KB )
- Solution-9-Sheet ( PDF , 106 KB )
- Solution-9-Code ( ZIP , 36 KB )
- Solution-10-Sheet ( PDF , 107 KB )
- Solution-10-Code-1 ( ZIP , 36 KB )
- Solution-10-Code-2 ( JAVA , 5 KB )
Additional Information
- Runtime System
- JavaDoc for the runtime system
- TPC-D data set