Generalized Independent Subqueries Method
Tomasz Marek Kowalski
1
, Radosław Adamus
1
, Jacek Wiślicki
1
and Michał Bleja
2
1
Computer Engineering Department, Technical University of Lodz, Lodz, Poland
2
Faculty of Mathematics and Computer Science, University of Lodz, Lodz, Poland
Keywords: Query Optimization, Independent Subqueries, Object-Oriented Database, Stack-Based Approach, SBQL.
Abstract: The following paper presents generalisation of the independent subquery method for object-oriented query
languages. A subquery is considered independent if none of involved names is bound in a stack section
opened by a currently evaluated non-algebraic operator. Optimisation of such a subquery is accomplished
by factoring it out from a loop implied by its query operator. We generalise the method to factor out also
subqueries that are evaluated only in a context of independent subqueries of a given query. The query is
rewritten to an equivalent form ensuring much better performance. Our research bases on the Stack-Based
Architecture of query languages having roots in semantics of programming languages. The paper illustrates
the method on an comprehensive example and finally presents the general rewriting rule.
1 INTRODUCTION
The ODRA system (Lentner and Subieta, 2007) is an
environment facilitating development of object-
oriented data-intensive and distributed applications.
The main component of ODRA is SBQL (Stack-
Based Query Language) (Lentner and Subieta, 2007;
Subieta, 2008 and 2009). SBQL evolved from a pure
database query language to a fully-fledged object-
oriented programming language with a lot of
features such as an UML-like object model,
collections constrained by cardinalities, processing
semi-structured data, static type-checking, closures,
etc. As a query language, SBQL is supported by a
query optimiser, which contains a set of optimisation
methods, including query rewriting (Płodzień,
2000), indices (Kowalski et al., 2008). We have
adapted and generalised some of them from
relational database systems, but in majority they are
totally new. In this paper we propose one of such
new powerful optimisation methods that has not
been presented yet in any source.
Analysing query evaluation in the Stack-Based
Approach (SBA) (Subieta, 2008) one can notice that
some subqueries are processed multiple times in
loops implied by non-algebraic operators, despite the
fact that in subsequent loop cycles their results are
the same. Such subqueries should be evaluated only
once and their result reused in next loop cycles. This
observation is a basis for an important rewriting
optimisation technique called the method of
independent subqueries (Płodzień and Kraken, 2000,
Płodzień, 2000). This method is more general than
classical pushing of a selection/projection known
from relational system and SQL (Ioannidis, 1996).
In SBA it works for any kind of a non-algebraic
query operator and for any object-oriented database
model.
The generalised independent subqueries method
belongs to the group of optimisation methods based
on query rewriting. Rewriting means transforming a
query Q
1
into a semantically equivalent query Q
2
providing much better performance. It is
accomplished according to rewriting rules based on
locating parts of a query matching some pattern.
These parts are to be replaced by other parts
according to these rules. The main benefit from
rewriting is that algorithms are fast, optimisation is
performed before a query is executed and resulting
performance improvement can be very significant,
sometimes several orders of magnitude (concerning
queries’ response times).
Presented method includes cases where an
independent query is divided into two or more parts
(within a larger query), which makes more difficult
to detect and factor out. We show that there is an
efficient rewriting rule to factor an independent
subquery out of a non-algebraic operator together
with its dependent subqueries that are also
independent of this operator. For example, consider
a query – for pairs being a Cartesian product of all
200
Marek Kowalski T., Adamus R., Wi
´
slicki J. and Bleja M..
Generalized Independent Subqueries Method.
DOI: 10.5220/0003994802000204
In Proceedings of the 14th International Conference on Enterprise Information Systems (ICEIS-2012), pages 200-204
ISBN: 978-989-8565-10-5
Copyright
c
2012 SCITEPRESS (Science and Technology Publications, Lda.)