Performing Group-By before Join

Weipeng Yan, Per-Åke Larson · 1994

Assume that we have an SQL query containing joins and a group-by. The standard way of evaluating this type of query is to rst perform all the joins and then the group-by operation. However, it may be possible to perform the group-byearly, that is, to push the group-by operation past one or more joins. Early grouping may reduce the query processing cost by reducing the amount of data participating in joins. We formally dene the problem, adhering strictly to the semantics of NULL and duplicate elimination in SQL2, and prove necessary and su cient conditions for deciding when this transformation is valid. In practice, it may beexpensive or even impossible to test whether the conditions are satis ed. Therefore, we also present a more practical algorithm that tests a simpler, su cient condition. This algorithm is fast and detects a large subclass of transformable queries.

Read the paper · More papers on PaperTik