<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta>
      <journal-title-group>
        <journal-title>” The VLDB Journal</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <article-id pub-id-type="doi">10.14778/2536222.2536233</article-id>
      <title-group>
        <article-title>On-the-Fly Filtering of Aggregation Results in Column-Stores</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Anastasia Tuchina</string-name>
          <email>anastasia.i.tuchina@gmail.com</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Valentin Grigorev</string-name>
          <email>valentin.d.grigorev@gmail.com</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>George Chernishev</string-name>
          <email>chernishev@gmail.com</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Saint Petersburg State University</institution>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Saint Petersburg State University, JetBrains Research</institution>
        </aff>
      </contrib-group>
      <pub-date>
        <year>1997</year>
      </pub-date>
      <volume>6</volume>
      <issue>11</issue>
      <fpage>1080</fpage>
      <lpage>1091</lpage>
      <abstract>
        <p>-Aggregation is a database operation that aims to provide basic analytic capabilities by partitioning source data into several groups and computing some function on values belonging to the same group. Nowadays it is common in databases, and especially in the OLAP domain, which is a primary venue for column-stores. In this paper we propose a novel approach to the design of an aggregation operator inside a column-store system. The core of our approach is an analysis of predicates in the HAVINGclause that allows the runtime pruning of groups. We employ monotonicity and codomain analysis in order to detect groups in which predicates would never be satisefid. Eventually, we aim to save I/O and CPU costs by discarding groups as early as possible. We start by providing a high-level overview of our approach and describe its use-cases. Then, we provide a short introduction into our system and describe a straightforward implementation of an aggregation operator. Next, we provide theoretical foundations for our approach and present an improved algorithm. Finally, we present an experimental validation of our approach inside PosDB - a distributed, disk-based column-store engine that features late materialization and block-oriented processing. Experiments using an SSD drive show that our approach can provide up to 5 times improvement over the naive version.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>I. INTRODUCTION</title>
      <p>
        Aggregation is rather common in databases and, in fact, it
forms the basis of OLAP. For example, the TPC-H
benchmark [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] does not contain a single query which does not
involve aggregation. Therefore, in the early 80’s the scientific
community recognized the importance of efficient aggregation
processing. While there are hundreds of studies concerning
aggregation in row-stores, the column-store processing is less
explored.
      </p>
      <p>
        Column-stores are a relatively recent development [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ].
Unlike classic approaches, where all attributes of every record
are kept together, column-stores employ the opposite idea —
they store each attribute separately. This leads to a number of
challenges as well as opportunities in query processing.
      </p>
      <p>In this paper we propose a novel technique intended
for optimizing the processing of aggregation queries inside
column-stores. Our approach concerns analysis of predicates
in the HAVING-clause and relies on a simple idea: terminate
processing of a group if, judging by the already processed data,
the HAVING-predicate will never be satisfied. Thus, it should
be possible to save I/O and CPU costs related to evaluation
of aggregation functions located in the SELECT-clause.</p>
      <p>In order to illustrate this, let us consider the following
example (adapted from Q1 of TPC-H):</p>
      <sec id="sec-1-1">
        <title>SELECT</title>
        <p>l r e t u r n f l a g , l l i n e s t a t u s ,
SUM( l q u a n t i t y ) a s sum qty ,
SUM( l e x t e n d e d p r i c e ) a s s u m b a s e p r i c e ,
SUM( l e x t e n d e d p r i c e ∗ ( 1 − l d i s c o u n t ) )
a s s u m d i s c p r i c e ,
SUM( l e x t e n d e d p r i c e ∗ ( 1 − l d i s c o u n t ) ∗
( 1 + l t a x ) ) a s s u m c h a r g e ,
AVG( l q u a n t i t y ) a s a v g q t y ,
AVG( l e x t e n d e d p r i c e ) a s a v g p r i c e ,
AVG( l d i s c o u n t ) a s a v g d i s c ,</p>
        <p>COUNT( ∗ ) a s c o u n t o r d e r
FROM l i n e i t e m
GROUP BY l r e t u r n f l a g , l l i n e s t a t u s
HAVING SUM( l q u a n t i t y ) &lt; 1 0 0 0 0 0 0
ORDER BY l r e t u r n f l a g , l l i n e s t a t u s
In this case naive processing can be organized as follows:
1) Rewrite query in the form</p>
        <p>SELECT ∗</p>
        <sec id="sec-1-1-1">
          <title>FROM ( original query without having ) WHERE having-clause</title>
          <p>2) Move aggregation expressions from the HAVING-clause
to the SELECT-clause of the original query if they are
not already present there, and perform aggregation as
usual (e.g. hash-based aggregation);
3) Filter aggregation results by the HAVING-predicate that
uses columns introduced in the step 2 and then eliminate
extra columns by projection.</p>
          <p>However, if during the second step the partial sum of
l_quantity for some group exceeds 1000000, it is possible
to discard this group immediately. In the column-store case,
this approach will allow us to save some I/O and CPU costs.</p>
          <p>At first glance, it may seem that the benefits of our
approach are rather limited, because joins incur more significant
costs than aggregation. However, there are aggregation queries
which do not involve joins, e.g. Q1 and Q6 in TPC-H. More
importantly, all queries in this benchmark try to mimic
reallife scenarios, and, thus, they represent an actual business need.
This indicates that similar queries can be encountered in
reallife workloads.</p>
          <p>Overall, there are several types of use-cases when our
approach would be of use:
1) Aggregation queries that do not involve joins:
aggregation running on a denormalized table, a materialized
view, solely on a fact table and so on;
2) A case where join operators produce roughly as much
data as they receive or even more, so aggregation
requires comparable time for processing.</p>
          <p>
            Unlike row-stores, column-stores offer an opportunity to
reap the fruits of such optimization with ease. In this paper
we consider this problem in the context of PosDB [
            <xref ref-type="bibr" rid="ref3">3</xref>
            ]–[
            <xref ref-type="bibr" rid="ref5">5</xref>
            ] —
a distributed disk-based column-store engine that features late
materialization and block-oriented processing. However, we
think that the proposed solution is sufficiently universal —
almost any column-store system can benefit from similar
optimization, regardless of its underlying architecture. Also,
despite the current columnar focus of our study, we believe that
our approach is applicable to hybrid systems and in-memory
DBMSes as well.
          </p>
          <p>Overall, the contribution of this paper is the following:
1) Theoretical basis for on-the-fly pruning of groups during
the evaluation of the aggregation operator.
2) An experimental study of our approach using PosDB.</p>
          <p>This paper is organized as follows. In Section II we present
a short introduction into PosDB and the aggregation operator.
Section III provides definitions and presents formal grounds
for our analysis. In Section IV we describe an optimized
version of the aggregation algorithm. Next, in Section V we
present an experimental evaluation and discuss current results.
Then, we survey existing aggregation studies in Section VI.
Finally, in Section VII we conclude our study and present
future work.</p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>II. QUERY PROCESSING IN POSDB</title>
      <p>
        In this section we will give a minimally sufficient
description of PosDB internals, and present the naive aggregation
algorithm. For a comprehensive description of the whole
system, see [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. Several surveys of column-store technology
are presented in references [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]–[
        <xref ref-type="bibr" rid="ref8">8</xref>
        ].
      </p>
      <sec id="sec-2-1">
        <title>A. Basics</title>
        <p>
          Query processing in PosDB is built upon the pull-based
Volcano model [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ] with block-oriented processing. According
to this model, each query is represented by a tree whose nodes
are physical operators and edges are data flows. Each operator
supports an iterator interface, and data is passed between
operators in blocks.
        </p>
        <p>
          Currently, PosDB supports late materialization only. This
is a query execution strategy for column-stores that aims to
defer the tuple reconstruction and materialization until as late
as possible. In order to implement this strategy, a special
intermediate representation, based on the join index from the
study [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ], was introduced. This representation links records of
different tables together. It is used to pass blocks of positional
data between operators.
        </p>
        <p>Some operators (e.g. joins) require not only positions, but
also attribute values. Therefore, in order to obtain attribute
values from the join index we employ a special entity —
a reader. There are two types of readers in PosDB that are
essential for understanding of our current study:
• ColumnReader is a reader for retrieving values of an
individual attribute. In fact, there are several subtypes
of ColumnReader, since our system supports data
partitioning and data distribution.
• SyncReader is a reader for retrieving values of several
attributes related to the same join index in a
row-byrow manner. It is implemented as a wrapper for several
ColumnReaders.</p>
      </sec>
      <sec id="sec-2-2">
        <title>B. Baseline version of aggregation algorithm</title>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Consider the following SQL query:</title>
      <sec id="sec-3-1">
        <title>SELECT T.A , T.B , COUNT(*) as count ,</title>
      </sec>
      <sec id="sec-3-2">
        <title>MAX(T.C) - MIN(T.C) as diff</title>
      </sec>
      <sec id="sec-3-3">
        <title>FROM T</title>
      </sec>
      <sec id="sec-3-4">
        <title>GROUP BY T.A , T.B</title>
        <p>HAVING count = 1
In this query, the three following components should be
distinguished:
1) GROUP BY clause. It contains a list of attributes that
are used to define groups. We will call these attributes
grouping parameters.
2) SELECT clause. It contains a list of expressions that
we will call aggregation expressions. In our study we
assume that only grouping parameters are allowed on
the top level. Other attributes should be wrapped in
aggregate functions, such as MAX, SUM, etc. Currently,
some database systems allow not only grouping
parameters, but arbitrary attributes on the top level as well,
e.g., MySQL and SQLite1. However, such
understanding of aggregation is unambiguous only if there is a
functional dependency between grouping parameters and
“raw” attributes on the top-level of SELECT clause.
Otherwise, it leads to uncertainty and, consequently, to
implementation-dependent behavior. It should be noted
that such understanding of aggregation is not prevalent in
the database community since it contradicts the SQL’92
standard (see sections 6.5 and 7.9).
3) HAVING clause. It contains a predicate that is applied to
the data regarding the whole group and is used to filter
resulting rows.</p>
        <p>Before describing the aggregation algorithm used in PosDB,
we should formally describe the admissible aggregation
expressions. They are inductively defined as follows.
Definition 1 A stateless expression is either:
• an identifier of an attribute belonging to a relation that
was mentioned in a FROM-clause (free variable);
• a constant of a supported data type (constant);
• A + B, A − B, A · B, A ÷ B, An, where A and B
are admissible numeric stateless expressions and n is a
non-negative integer (arithmetic expressions);</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>1https://stackoverflow.com/questions/1023347/</title>
      <p>mysql-selecting-a-column-not-in-group-by</p>
      <p>An aggregation expression is either:
• an identifier of any attribute belonging to grouping
pa</p>
      <p>rameters;
• a constant of a supported data type;
• COUNT(E), MAX(E), MIN(E), SUM(E), AVG(E),
where E is an admissible stateless expression. In this
case, we will call such expressions aggregates.
• A + B, A − B, A · B, A ÷ B, An, where A and B
are admissible numeric aggregation expressions and n is
a non-negative integer. In this case, we will call such
expressions aggregation arithmetic expressions.</p>
      <p>an individual copy should be maintained for each group) and
a new entry is added to the hash table. Otherwise, it already
exists in the hash table and, thus, the corresponding aggregates
should be updated.</p>
      <p>In the end of the aggregate evaluation stage, each individual
entry of the hash table contains computed aggregates for a
particular group. Next, at the result generation stage, the hash
table is iterated through. During this process, the algorithm
computes aggregation expressions, constructs full tuples and
returns them to a parent operator.</p>
      <p>If the considered query contains a HAVING-clause then a
parent operator performing filtering of results is added. In</p>
      <p>PosDB this operator is implemented as filtering on tuples.</p>
      <p>Other types of expressions can be added later in a similar
manner.</p>
      <p>Both stateless and aggregation expressions may appear in III. PRUNING POSSIBILITY ANALYSIS
the SELECT clause. Joint usage of these expressions on the top The core of the proposed approach is HAVING-predicate
level of the SELECT clause is prohibited: stateless expressions analysis. It consists of two components: monotonicity
analshould be used if there is no aggregation, and aggregation ysis and codomain analysis. Let us begin with an inductive
expressions otherwise. As can be seen from the definition, definition of admissible (correct in the context of a
HAVINGstateless expressions are also used as subexpressions for ag- clause and currently supported) predicates.
gregates. Definition 3 The following predicates are admissible:</p>
      <p>Let us now consider the semantics of stateless expressions. • A = B, A 6= B, A &gt; B, A &lt; B, A ≤ x ≤ B, where
Here, we consider an abstract processing scheme rather than A, B and x are admissible aggregation expressions or
focusing purely on row- or column-stores. Consider row-by- constants (atomic predicates).
row scanning of a relation. A stateless expression is a “pure • P ∧ Q, P ∨ Q, where P and Q are admissible predicates
function”: it takes a row as an input and produces a result (compound predicates).
immediately. On the other hand, aggregation expression can
produce a result only when the whole group is processed. Other types of predicates can be added later in the same
During group processing, values of aggregates that compose an way. Currently, we support numeric types only.
aggregation expression should be updated for each incoming A. Monotonicity analysis
row. These updates lead to change of the “current” value of
the aggregation expression involving these aggregates. Thus, Consider an aggregation expression from a fixed group.
during processing aggregation expressions pass through a As we mentioned earlier, throughout the execution of the
sequence of intermediate states. Monotonicity analysis of such aggregation algorithm the “current” value of this expression
sequences is a central part of the current study. changes several times and, thus, forms a sequence. Often we</p>
      <p>Concerning implementation, we must emphasize that in can guarantee monotonicity of these sequences by analyzing
case of a disk-based column-store, expressions should use the properties of the corresponding aggregates. Therefore, we
an interface which allows on-demand column reading. This can talk about monotonicity of aggregation expressions itself.
requirement is essential in order to reduce the number of disk Aggregates are monotonic in the following way:
accesses. In PosDB, SyncReader provides this functionality. • COUNT(E) is weakly increasing;</p>
      <p>
        Let us now turn to the aggregation operator itself. Its inputs • MAX(E) is weakly increasing;
are grouping parameters and a list of aggregation expressions. • MIN(E) is weakly decreasing;
The local state [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ] of the aggregation operator is a hash table • SUM(E) is
with tuples composed of grouping parameters used as keys – weakly increasing if E ≥ 0,
and lists of aggregates extracted from aggregation expressions – weakly decreasing if E ≤ 0,
used as values. – constant, if E ≡ 0,
      </p>
      <p>In a general case, aggregation is an operation that requires – not monotonic otherwise;
full materialization of the corresponding relation, i.e. it should • AVG(E) is not monotonic.
process all data in order to produce the first result. Thus, it Note that during algorithm execution values of grouping
can be decomposed into two stages: aggregate evaluation and parameters belonging to a particular group do not change.
result generation. The aggregate evaluation stage is the core Values of constant expressions behave in a similar manner.
of the operator. It is organized as a loop over logical “rows” Thus, the former should be considered as constants as well.
(provided by the corresponding reader in case of PosDB). On If we denote weakly increasing aggregation expressions as
each iteration of the loop a new key-tuple is created and the E↑ and weakly decreasing ones as E↓, then we can derive
hash table is probed. If a corresponding record is not found, monotonicity of aggregation arithmetic expressions according
then the aggregates are cloned (they have a state, therefore, to the following rules:
to assess their monotonicity. This analysis consists of checking
whether E ≥ 0, E ≤ 0 or E ≡ 0. It can be carried out
using codomain analysis of corresponding stateless numeric
expressions.</p>
      <p>
        Our codomain analysis is based on well-known interval
analysis [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ]. We support open, closed and half-closed
intervals. Their endpoints can be infinite. Constants are represented
by degenerate intervals.
      </p>
      <p>The following operators of interval arithmetic are used to
compute the codomain of an arithmetic expression:
if n is even,</p>
      <p>x1 ≤ 0, x2 ≤ 0
if n is even,
x1 ≤ 0, x2 ≤ 0</p>
      <p>n is even,
x1 ≤ 0, x2 ≥ 0
if n is even,</p>
      <p>x1 ≥ 0, x2 ≥ 0
if n is odd
• E1↑ + E↑, E1↑ − E2↓ are weakly increasing;</p>
      <p>2
• E1↓ + E↓, E1↓ − E2↑ are weakly decreasing;</p>
      <p>2
• if E1 ≥ 0 and E2 ≥ 0:
– E1↑ · E2↑, E1↑ ÷ E2↓ are weakly increasing;
– E1↓ · E2↓, E1↓ ÷ E2↑ are weakly decreasing;
• if E1 ≥ 0 and E2 ≤ 0:
– E1↑ ÷ E2↑, E1↑ · E2↓ are weakly decreasing;
– E1↓ ÷ E2↓, E1↓ · E2↑ are weakly increasing;
• if E1 ≤ 0 and E2 ≥ 0:
– E1↑ ÷ E2↑, E1↑ · E2↓ are weakly increasing;
– E1↓ ÷ E2↓, E1↓ · E2↑ are weakly decreasing;
• if E1 ≤ 0 and E2 ≤ 0:
– E1↑ · E2↑, E1↑ ÷ E2↓ are weakly decreasing;
– E1↓ · E2↓, E1↓ ÷ E2↑ are weakly increasing;
• for other cases, we cannot guarantee monotonicity of the</p>
      <p>result.</p>
      <p>Proof of these statements obviously follows from the
properties of arithmetic operations on inequalities.</p>
      <p>Let us now turn to HAVING-predicate analysis. We start
with atomic predicates and then generalize our approach to
the compound ones.</p>
      <p>The following predicate types allow to terminate processing
of a particular group earlier if the corresponding termination
condition is satisfied:</p>
    </sec>
    <sec id="sec-5">
      <title>Predicate type Termination condition</title>
      <p>E↓ &gt; E↑ E↓ ≤ E↑
E↑ &lt; E↓ E↓ ≥ E↑
E↓ = E↑ E↓ &lt; E↑</p>
      <p>E↑ = E↓ E↓ &gt; E↑</p>
      <p>The first column contains the predicate type, which is
essentially a predicate with free variables. In contrast, the
second column contains an “implementation” of the
corresponding predicate where intermediate values of aggregates
are substituted instead of being free variables. In our study
we refer to both of these entities as predicates. Thus,
Definition 4 Potentially terminating predicate is a predicate
that has a termination condition.</p>
      <p>Definition 5 Terminating predicate is a predicate that has its
termination condition fulfilled by a particular instance of data.</p>
      <p>The following statements hold for compound predicates:
• P1 ∧ P2 is potentially terminating, if P1 or P2 is
potentially terminating.
• P1 ∧ P2 is terminating, if P1 or P2 is terminating.
• P1 ∨ P2 is potentially terminating, if both P1 and P2 are
potentially terminating.</p>
      <p>• P1 ∨ P2 is terminating, if both P1 and P2 are terminating.</p>
      <sec id="sec-5-1">
        <title>B. Codomain analysis</title>
        <p>As shown earlier, there are several important cases —
aggregate SUM(E), aggregation arithmetic expressions containing
multiplication and division — that require additional analysis
Information about possible values of attributes is taken from
the meta-information based on the CHECK-constraints stored
in the catalog.</p>
        <p>Concerning endpoint inclusion, it should be noted that
inclusion is kept if and only if operation is applied to included
endpoints. Otherwise, an endpoint is excluded.</p>
        <p>Note that there is an issue with the interval arithmetics.
Estimates obtained by its application strongly depend on the
form of an expression. For example, consider the expression
x/(1−x), for which two different intervals can be obtained —
one for x/(1 − x) and another for 1/(1/x − 1). However, it
is guaranteed that all intervals would contain the range of the
analyzed function.</p>
        <p>Currently, it is unclear whether it would be useful to employ
more complicated (and more resource-consuming) approaches
to get better estimates in case of our algorithm.</p>
        <p>Another aspect that should be discussed is the input of
operators. Codomain may be described not by a single interval,
but by a union of several disjunctive intervals. Thus, operators
may also produce unions of several intervals. In our study
we restrict ourselves to supporting only a single interval per
attribute.</p>
      </sec>
    </sec>
    <sec id="sec-6">
      <title>IV. OPTIMIZED AGGREGATION ALGORITHM</title>
      <p>We are now ready to present an optimized version of
the aggregation algorithm described in the section II-B. Our
algorithm combines both aggregation and filtering into a single
operator. Therefore, the interface of the aggregation operator
was slightly changed — now it also receives a
HAVINGpredicate as a parameter. If there is no HAVING-clause in the
query, then a non-optimized version should be run.</p>
      <p>The optimized algorithm tracks the state of the predicate for
each group, so several changes should be introduced into the
hash table. Now this table contains entries that are structures
with the following fields:
• A list of aggregates that should be evaluated eventually
(as in the baseline version). Here we will call such
aggregates primary aggregates.
• A copy of the HAVING-predicate to check whether it is
necessary to further process the current group.
• A list of aggregates from the HAVING-predicate that are
used to compute the state of the corresponding
HAVINGpredicate copy. We will call them auxiliary aggregates.</p>
      <p>The optimized algorithm requires a new stage — a
predicate analysis stage. At this stage, the HAVING-predicate
is analyzed using the approaches described in the previous
section. If it is potentially terminating, then it will be possible
to perform earlier termination of processing of any group
when the corresponding termination condition is satisfied for
this group. Otherwise, the baseline version of aggregation
algorithm should be used.</p>
      <p>Optimization itself is mostly applied at the aggregate
evaluation stage. As in the baseline version of algorithm, we
iterate through the logical “rows” (provided by SyncReader
in PosDB). Inside the loop we check if the corresponding
group already exists in the hash table. However, now we
need to check the state of the predicate copy as well. If
there is no such group, we clone the predicate, extract the
aggregates (auxiliary) from it, update their values and evaluate
the predicate. If the predicate is not terminating yet, then we
also clone the primary aggregates and add a record to the hash
table. If the predicate is already terminating, then we delete
the cloned predicate and add a “tombstone” into the hash table
instead of a normal record.</p>
      <p>If the corresponding group is already in the hash table, and
it was not “tombstoned”, then we update the values of both
primary and auxiliary aggregates from the predicate, and check
the status of the predicate. If it becomes terminating, then we
delete the found record and replace it with a “tombstone”.
Otherwise, we just proceed to the next logical “row” without
fetching values needed for computation of both primary and
auxiliary aggregates. It is this step of the algorithm that makes
I/O and CPU savings possible.</p>
      <p>At the result generation stage, we iterate over the hash
table, skip groups that have been “tombstoned” and check
the HAVING-predicate for the remaining groups. Next, tuples
constructed from records that satisfy the predicate are passed
to the parent operator.</p>
    </sec>
    <sec id="sec-7">
      <title>V. EXPERIMENTS</title>
      <p>Experimental evaluation was performed on a PC with the
following characteristics: 4-core Intel R CoreTM i5-7300HQ
CPU @ 2.50GHz, 8 Gb RAM, running Linux Ubuntu 16.04.1
LTS. 128GB KINGSTON RBU-SNS SSD was used as storage.</p>
      <p>Test queries are based on Q1 from TPC-H. The first four
of them have the following form:</p>
      <sec id="sec-7-1">
        <title>SELECT</title>
        <p>l r e t u r n f l a g , l l i n e s t a t u s ,
SUM( l q u a n t i t y ) a s sum qty ,
SUM( l e x t e n d e d p r i c e ) a s s u m b a s e p r i c e ,
SUM( l e x t e n d e d p r i c e ∗ ( 1 − l d i s c o u n t ) )
a s s u m d i s c p r i c e ,
SUM( l e x t e n d e d p r i c e ∗ ( 1 − l d i s c o u n t ) ∗
( 1 + l t a x ) ) a s s u m c h a r g e ,
AVG( l q u a n t i t y ) a s a v g q t y ,
AVG( l e x t e n d e d p r i c e ) a s a v g p r i c e ,
AVG( l d i s c o u n t ) a s a v g d i s c ,</p>
        <p>COUNT( ∗ ) a s c o u n t o r d e r
FROM l i n e i t e m
GROUP BY l r e t u r n f l a g , l l i n e s t a t u s
HAVING having-clause
where having-clause is
• l_linestatus = ’O’ for Q1;
• having count(*) &lt; 100000 for Q2;
• (l_returnflag = ’A’) OR
(l_linestatus = ’O’)) AND
(MIN(l_tax) &gt; MAX(l_discount) for Q3;
• SUM(l_quantity) &lt; 1000000 for Q4.</p>
        <p>These queries are designed for studying how optimization
is affected by different kinds of predicates. All of them are
supposed to demonstrate significant performance improvement
due to avoidance of unnecessary I/O in the optimized
algorithm.</p>
        <p>We have also designed the Q5 query for a first, rough
appraisal of the overhead introduced by our algorithm. Q5
is an example of a query where no performance improvement
could be gained due to absence of I/O savings. In this query,
all columns have to be read regardless of predicate values.</p>
      </sec>
    </sec>
    <sec id="sec-8">
      <title>SELECT l r e t u r n f l a g , l l i n e s t a t u s , FROM l i n e i t e m GROUP BY l r e t u r n f l a g , l l i n e s t a t u s HAVING l r e t u r n f l a g = ’A ’</title>
      <p>For each combination of an algorithm and a scale factor
(SF) we have run all the aforementioned queries 10 times and
calculated the 95% confidence intervals. The full results of
the experiments are presented in the Table I. We have also
visualized the results for SF = 50 in Fig. 1 to make it more
illustrative.</p>
      <p>As we can see from Table I, there is no considerable
performance dependency on the predicate complexity — queries Q2–
Q4 show very close results on all scale factors. On the other
side, as expected, optimization efficiency significantly depends
Algorithm
Optimized
Baseline
Optimized
Baseline
Optimized
Baseline
Optimized
Baseline
Optimized
Baseline</p>
      <p>SF = 1
2087 ms ±2%
3305 ms ±2%
841 ms ±1%
3293 ms ±3%
687 ms ±1%
3458 ms ±2%
766 ms ±1%
3511 ms ±2%
510 ms ±1%
504 ms ±1%
on the predicate selectivity and on the time when pruning can
be performed. We suppose that the difference between Q1 and
Q2–Q4 should be explained by this fact. Detailed analysis of
these factors was postponed for the future.</p>
      <p>Evaluation of Q5 shows that the overhead introduced by our
algorithm is rather small (about 2–3%) and does not depend
on the scale factor.</p>
      <p>Concerning the dependency on the scale factor, it is looking
close to linear for all the considered queries.</p>
    </sec>
    <sec id="sec-9">
      <title>VI. RELATED WORK</title>
      <p>
        According to reference [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ], the processing of aggregation
queries has been studied at least since the end of the 70’s [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ].
Nowadays, it is a mature area of research which features
hundreds of papers [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ].
      </p>
      <p>
        These studies can be roughly classified into the following
groups:
1) Optimization of aggregation queries. In these papers
authors study how to efficiently process aggregation
queries mostly by using various plan transformations. In
the study [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ], [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ], the authors propose two
transformations: eager aggregation (moving a GROUP BY down
through join) and lazy aggregation (moving a GROUP
BY up). The former allows to reduce the number of
entries that need to be processed by the join operator, and,
consequently, to improve the overall query processing
performance. The latter is of interest when the query
operates on a view containing a GROUP BY. A similar
transformation is proposed in study [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ]. The core of this
approach is to pre-aggregate data using any column set
that functionally determines the table being aggregated.
In study [
        <xref ref-type="bibr" rid="ref16">16</xref>
        ] authors integrate subquery and aggregation
processing techniques by proposing a set of shared
primitives. Then these primitives are used to generate
optimized plans. The problem of aggregation query
optimization in the OLAP environment was considered in
reference [
        <xref ref-type="bibr" rid="ref17">17</xref>
        ]. In this paper, an analysis of an approach
called Hierarchical Pre-Grouping is performed and a
number of transformations is proposed and analyzed.
2) Optimization of evaluation of an individual aggregation
operator. These studies aim to organize processing in
the most efficient way. There are two basic methods for
performing an aggregation [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ] — hashing and sorting.
According to reference [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ] sorting was considered in
study [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ]. Among contemporary studies it is essential
to note Blink [
        <xref ref-type="bibr" rid="ref18">18</xref>
        ], where authors consider aggregating
compressed data and reference [19] where
hardwareefficient multi-threaded aggregation in column-store was
presented. However, none of these studies analyzed
aggregation predicates in order to improve individual
operator performance.
3) A relatively recent approach called online aggregation.
      </p>
      <p>Its goal is to provide the database user with means
to control the execution of aggregation. The proposed
use-case is the following: while processing data,
progressively refine an approximate answer and provide its
running confidence intervals. Unlike plain aggregation,
where the user passively waits for the answer, this
approach allows the user to terminate a query early
if they deem the approximate results acceptable.
Originally, this approach was proposed in reference [20],
and later, many studies have followed. For example,
the study [21] extends this idea onto nested queries
that contain aggregation and also proposes a
multithreaded model. Next, the paper [22] addresses parallel
aggregation on a cluster of computers.
4) Another group of papers studied approximate processing
of aggregation queries. Unlike the previous approach,
this type of studies does not imply user intervention
during the processing. Approximate aggregation query
answering using sampling was studied in reference [23].
The idea of this paper is to index outlying values in
order to reduce the approximation error. The study [24]
addresses the problem of approximate time-constrained
query evaluation. The authors propose an algorithm for
evaluating count-containing aggregation queries that can
be stopped if the desired error range is obtained or the
pre-specified time limit is exceeded.
5) Novel models of aggregation and novel aggregations
operators. Horizontal aggregation is proposed in
reference [25]. Its idea is to generate a new table, where
a separate column for each unique value of columns
belonging to aggregation expression is generated. At the
same time, the rows of this table contain all unique
values from the columns of GROUP BY list. The authors of
this paper propose not only semantics of this operation,
but also language extension and discuss query execution.
Similarly, reference [26] describes two aggregation-like
operators: PIVOT and UNPIVOT. The former
transforms a series of rows into a series of fewer rows
with additional columns. Data in one source column
is used to generate the new column for a row, and
another source column is used as the data for that new
column. The latter performs the inverse operation by
removing a number of columns and creating additional
rows. In studies [27], [28] novel aggregation operators
are proposed. The former study considers embedding
of grouping variables [29] into SQL queries. Grouping
variables is a tool that allows to specify additional
conditions for the desired groups. It is much more
expressive than HAVING-clause. The latter study proposes
a generalization of an aggregation operator that allows
formation of aggregation groups without requiring an
ordering of the data relation.</p>
    </sec>
    <sec id="sec-10">
      <title>VII. CONCLUSION</title>
      <p>In this paper we have proposed a novel approach to
evaluation of aggregation in column-stores. We employ monotonicity
and codomain analysis in order to invoke early termination that
allows to save CPU and I/O costs. To validate our idea, we
have implemented the designed algorithms inside a disk-based
column-store query engine. Preliminary experiments show that
our approach can improve query performance up to 5 times
over the naive algorithm.</p>
      <p>In our future studies we plan to evaluate performance
dependency on the number of groups, data distribution, selectivity
and complexity of the predicate. We also going to assess
the overhead introduced by our algorithm in more detail.
Other future studies may include combining proposed operator
with other approaches to aggregation (e.g. partial aggregation
approach), applying it for in-memory systems, and exploring
opportunities offered by novel hardware.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>Transaction</given-names>
            <surname>Processing Performance Council</surname>
          </string-name>
          ,
          <string-name>
            <surname>“TPC Benchmark TM H Standard Specification</surname>
          </string-name>
          <article-title>Revision 2</article-title>
          .
          <fpage>17</fpage>
          .3.” [Online]. Available: http: //www.tpc.org/tpc documents current versions/pdf/tpc-h
          <year>v2</year>
          .
          <year>17</year>
          .3.pdf
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>Stavros</given-names>
            <surname>Harizopoulos</surname>
          </string-name>
          , Daniel Abadi, and Peter Boncz, “ColumnOriented Database Systems,”
          <year>2009</year>
          . [Online]. Available: http://nms. csail.mit.edu/∼stavros/pubs/tutorial2009-column stores.pdf
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>G.</given-names>
            <surname>Chernishev</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Galaktionov</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Grigorev</surname>
          </string-name>
          , E. Klyuchikov, and
          <string-name>
            <given-names>K.</given-names>
            <surname>Smirnov</surname>
          </string-name>
          , “PosDB:
          <string-name>
            <given-names>A Distributed</given-names>
            <surname>Column-Store</surname>
          </string-name>
          <string-name>
            <surname>Engine</surname>
          </string-name>
          ,” in Perspectives of System Informatics,
          <string-name>
            <given-names>A. K.</given-names>
            <surname>Petrenko</surname>
          </string-name>
          and
          <string-name>
            <surname>A</surname>
          </string-name>
          . Voronkov, Eds. Cham: Springer International Publishing,
          <year>2018</year>
          , pp.
          <fpage>88</fpage>
          -
          <lpage>94</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4] -, “
          <article-title>A study of PosDB Performance in a Distributed Environment,” in Proceedings of the 2017 Software Engineering and Information Management, ser</article-title>
          .
          <source>SEIM '17</source>
          ,
          <year>2017</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5] -,
          <source>“PosDB: An Architecture Overview,” Programming and Computer Software</source>
          , vol.
          <volume>44</volume>
          , no.
          <issue>1</issue>
          , pp.
          <fpage>62</fpage>
          -
          <lpage>74</lpage>
          ,
          <year>Jan 2018</year>
          . [Online]. Available: https://doi.org/10.1134/S0361768818010024
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>Daniel</given-names>
            <surname>Abadi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Peter</given-names>
            <surname>Boncz</surname>
          </string-name>
          , and
          <article-title>Stavros Harizopoulos, The Design and Implementation of Modern Column-Oriented Database Systems</article-title>
          . Hanover, MA, USA: Now Publishers Inc.,
          <year>2013</year>
          . [Online]. Available: http://db.csail.mit.edu/pubs/abadi-column-stores.pdf
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>G.</given-names>
            <surname>Chernishev</surname>
          </string-name>
          , “
          <article-title>The design of an adaptive column-store system</article-title>
          ,
          <source>” Journal of Big Data</source>
          , vol.
          <volume>4</volume>
          , no.
          <issue>1</issue>
          , p.
          <fpage>5</fpage>
          ,
          <string-name>
            <surname>Mar</surname>
          </string-name>
          <year>2017</year>
          . [Online]. Available: https://doi.org/10.1186/s40537-017-0069-4
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>S.</given-names>
            <surname>Idreos</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Groffen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Nes</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Manegold</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K. S.</given-names>
            <surname>Mullender</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M. L.</given-names>
            <surname>Kersten</surname>
          </string-name>
          , “
          <article-title>MonetDB: Two Decades of Research in Column-oriented Database Architectures,” IEEE Data Eng</article-title>
          .
          <source>Bull.</source>
          , vol.
          <volume>35</volume>
          , no.
          <issue>1</issue>
          , pp.
          <fpage>40</fpage>
          -
          <lpage>45</lpage>
          ,
          <year>2012</year>
          . [Online]. Available: http://sites.computer.org/debull/ A12mar/monetdb.pdf
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>G.</given-names>
            <surname>Graefe</surname>
          </string-name>
          , “
          <article-title>Query Evaluation Techniques for Large Databases</article-title>
          ,
          <source>” ACM Comput. Surv.</source>
          , vol.
          <volume>25</volume>
          , no.
          <issue>2</issue>
          , pp.
          <fpage>73</fpage>
          -
          <lpage>169</lpage>
          , Jun.
          <year>1993</year>
          . [Online]. Available: http://doi.acm.
          <source>org/10</source>
          .1145/152610.152611
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>Z.</given-names>
            <surname>Li</surname>
          </string-name>
          and
          <string-name>
            <given-names>K. A.</given-names>
            <surname>Ross</surname>
          </string-name>
          , “
          <article-title>Fast Joins Using Join Indices,”</article-title>
          <source>The VLDB Journal</source>
          , vol.
          <volume>8</volume>
          , no.
          <issue>1</issue>
          , pp.
          <fpage>1</fpage>
          -
          <lpage>24</lpage>
          , Apr.
          <year>1999</year>
          . [Online]. Available: http://dx.doi.org/10.1007/s007780050071
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>G.</given-names>
            <surname>Alefeld</surname>
          </string-name>
          and G. Mayer, “
          <article-title>Interval analysis: theory and applications</article-title>
          ,
          <source>” Journal of Computational and Applied Mathematics</source>
          , vol.
          <volume>121</volume>
          , no.
          <issue>1-2</issue>
          , pp.
          <fpage>421</fpage>
          -
          <lpage>464</lpage>
          , Aug.
          <year>2000</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>R.</given-names>
            <surname>Epstein</surname>
          </string-name>
          , “
          <article-title>Techniques for Processing of Aggregates in Relational Database Systems</article-title>
          ,” Univ. of California, Berkeley, Tech. Rep.,
          <volume>01</volume>
          1979.
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <given-names>I. F. V.</given-names>
            <surname>Lopez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R. T.</given-names>
            <surname>Snodgrass</surname>
          </string-name>
          , and
          <string-name>
            <given-names>B.</given-names>
            <surname>Moon</surname>
          </string-name>
          , “
          <article-title>Spatiotemporal aggregate computation: a survey,” IEEE Transactions on Knowledge and Data Engineering</article-title>
          , vol.
          <volume>17</volume>
          , no.
          <issue>2</issue>
          , pp.
          <fpage>271</fpage>
          -
          <lpage>286</lpage>
          ,
          <year>Feb 2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <given-names>W. P.</given-names>
            <surname>Yan and P.-A. Larson</surname>
          </string-name>
          , “Eager Aggregation and Lazy Aggregation,”
          <source>in Proceedings of the 21th International Conference on Very Large Data Bases, ser. VLDB '95</source>
          . San Francisco, CA, USA: Morgan Kaufmann Publishers Inc.,
          <year>1995</year>
          , pp.
          <fpage>345</fpage>
          -
          <lpage>357</lpage>
          . [Online]. Available: http://dl.acm.org/citation.cfm?id=
          <volume>645921</volume>
          .
          <fpage>673154</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <given-names>P. A.</given-names>
            <surname>Larson</surname>
          </string-name>
          , “
          <article-title>Data reduction by partial preaggregation</article-title>
          ,”
          <source>in Proceedings 18th International Conference on Data Engineering</source>
          ,
          <year>2002</year>
          , pp.
          <fpage>706</fpage>
          -
          <lpage>715</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          [16]
          <string-name>
            <given-names>C.</given-names>
            <surname>Galindo-Legaria</surname>
          </string-name>
          and
          <string-name>
            <given-names>M.</given-names>
            <surname>Joshi</surname>
          </string-name>
          , “
          <article-title>Orthogonal Optimization of Subqueries and Aggregation,” in Proceedings of the 2001 ACM SIGMOD International Conference on Management of Data, ser</article-title>
          .
          <source>SIGMOD '01</source>
          . New York, NY, USA: ACM,
          <year>2001</year>
          , pp.
          <fpage>571</fpage>
          -
          <lpage>581</lpage>
          . [Online]. Available: http://doi.acm.
          <source>org/10</source>
          .1145/375663.375748
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          [17]
          <string-name>
            <given-names>A.</given-names>
            <surname>Tsois</surname>
          </string-name>
          and
          <string-name>
            <given-names>T.</given-names>
            <surname>Sellis</surname>
          </string-name>
          , “
          <article-title>The Generalized Pre-grouping Transformation: Aggregate-query Optimization in the Presence of Dependencies,”</article-title>
          <source>in Proceedings of the 29th International Conference on Very Large Data Bases -</source>
          Volume
          <volume>29</volume>
          ,
          <article-title>ser</article-title>
          .
          <source>VLDB '03. VLDB Endowment</source>
          ,
          <year>2003</year>
          , pp.
          <fpage>644</fpage>
          -
          <lpage>655</lpage>
          . [Online]. Available: http://dl.acm.org/citation.cfm? id=
          <volume>1315451</volume>
          .
          <fpage>1315507</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          [18]
          <string-name>
            <given-names>V.</given-names>
            <surname>Raman</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Swart</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Qiao</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Reiss</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Dialani</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Kossmann</surname>
          </string-name>
          ,
          <string-name>
            <surname>I. Narang</surname>
          </string-name>
          , and
          <string-name>
            <given-names>R.</given-names>
            <surname>Sidle</surname>
          </string-name>
          , “
          <string-name>
            <surname>Constant-Time Query</surname>
            <given-names>Processing</given-names>
          </string-name>
          ,”
          <source>in Proceedings of the 2008 IEEE 24th International Conference on Data Engineering</source>
          , ser.
          <source>ICDE '08</source>
          . Washington, DC, USA: IEEE Computer Society,
          <year>2008</year>
          , pp.
          <fpage>60</fpage>
          -
          <lpage>69</lpage>
          . [Online]. Available: http://dx.doi.org/10.1109/ICDE.
          <year>2008</year>
          .4497414
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>