and aggregate functions (Yan and Larson, 1994). It is
also insensitive to data skew and its communication
and Input/Output costs are reduced to a minimum.
In this algorithm, we partially evaluate the aggre-
gate function before redistributing the tuples. This
helps in reducing the cost of data redistribution. We
use the histograms of both relations in order to find
the tuples that participate in the result of the join oper-
ation. It is proved in (Bamha and Hains, 2005; Bamha
and Hains, 2000), using the BSP model, that his-
togram management has a negligible cost when com-
pared to the gain it provides in reducing the commu-
nication cost.
In traditional algorithms, all the tuples of the output of
the join are redistributed using a hash function. In the
contrary, in our algorithm we only redistribute the re-
sult of the semi-join of the histograms which are very
small compared to the size of input relations. This
helps in reducing the amount of data transferred over
the network and therefore the communication cost.
The performance of this algorithm is analyzed using
the BSP cost model which predicts for our algorithm
a linear speedup even for highly skewed data.
2 COMPUTATION OF
”GROUPBY-JOIN” QUERIES
In DBMS, we can distinguish two types of ”GroupBy-
Join” queries. In the first type the join attributes and
the group-by attributes are the same. In this case,
it is preferable to carry out the group-by and aggre-
gate functions first and then the join operation (Taniar
et al., 2000), because this helps in reducing the size
of the relations to be joined and consequently de-
creasing the communication cost and the query exe-
cution time. In the contrary, this can not be applied
on the second type of queries, because the join at-
tributes are different from the group-by attributes
see
(Al Hajj Hassan and Bamha, 2007) for a long and de-
tailed version of this paper
. In this paper, we will fo-
cus on this type of ”GroupBy-Join” queries where we
present an algorithm which partially evaluates the ag-
gregate functions before redistributing the tuples us-
ing histograms, thus reducing the communication cost
as much as possible.
3 GROUPBY-JOIN QUERIES: A
NEW APPROACH
In this section, we present a detailed description
of a new parallel algorithm used to evaluate the
”GroupBy-Join” queries when the group-by attributes
are different from the join attributes. We assume
that the relation R (resp. S) is evenly partitioned
among processors by horizontal fragmentation such
that |R
i
| ≃
|R|
p
(i = 1, ..., p) where p is the number
of processors.
For simplicity of description and without loss of gen-
erality, we consider that the query has only one join
attribute x and that the group-by attribute set consists
of one attribute y of R and another attribute z of S.
We also assume that the aggregate function is applied
on the values of the attribute u of S.
In the rest of this paper we use the following nota-
tion for each relation T ∈ {R, S}:
• T
i
denotes the fragment of relation T placed on
processor i, a sub-relation of T ,
• Hist
w
(T ) denotes the histogram
1
of relation T
with respect to the attribute w, i.e. a list of pairs
(v, n
v
) where n
v
6= 0 is the number of tuples of
relation T having the value v for the attribute w.
The histogram is often much smaller and never
larger than the relation it describes,
• Hist
w
(T
i
) denotes the histogram of fragment T
i
while Hist
w
i
(T ) is processor i’s fragment of the
histogram of T ,
• Hist
w
(T )(v) is the frequency (n
v
) of value v in
relation T while Hist
w
(T
i
)(v) is its frequency in
sub-relation T
i
,
• AGGR
w
f,u
(T )
2
is the result of applying the aggre-
gate function f on the values of the attribute u of
every group of tuples of T having identical val-
ues of the group-by attributes w. AGGR
w
f,u
(T ) is
formed of a list of tuples (v, f
v
) where f
v
is the
result of applying the aggregate function on the
group of tuples having value v for the attribute w
(w may be formed of more than one attribute),
• AGGR
w
f,u
(T
i
) denotes the result of applying the
aggregate function on the attribute u of relation
T
i
while AGGR
w
f,u,i
(T ) is processor i’s fragment
of the result of applying the aggregate function on
T ,
• AGGR
w
f,u
(T )(v) (resp.AGGR
w
f,u
(T
i
)(v)) is the re-
sult f
v
of the aggregate function of the group of
tuples having value v for the group-by attribute w
in relation T (resp. T
i
),
• kT k denotes the number of tuples of relation T ,
and |T | denotes the size (expressed in bytes or
number of pages) of relation T .
1
Histograms are implemented as a balanced tree (B-
tree): a data structure that maintains an ordered set of data
to allow efficient search and insert operations.
2
AGGR
w
f,u
(T ) is implemented as a B-tree.
AN OPTIMAL EVALUATION OF GROUPBY-JOIN QUERIES IN DISTRIBUTED ARCHITECTURES
247