Docsity

Date Cube Approximation and Histogram Via Wavelets | CSCI 585, Papers of Deductive Database Systems

Toggle sidebar
bg1
Data Cube Approximation and Histograms via Wavelets
(Extended Abstract)
Jerey Scott Vitter
Center for Geometric Computing
and Department of Computer Science
Duke University
Durham, NC 27708{0129 USA
Min Wang
y
Center for Geometric Computing
and Department of Computer Science
Duke University
Durham, NC 27708{0129 USA
Bala Iyer
Database Technology Institute
IBM Santa Teresa Laboratory
P.O. Box 49023
San Jose, CA 95161 USA
Abstract
There has recently been an explosion of interest in the analy-
sis of data in data warehouses in the eld of On-Line Analyt-
ical Processing (OLAP). Data warehouses can b e extremely
large, yet obtaining quick answers to queries is important.
In many situations, obtaining the exact answer to an OLAP
query is prohibitively expensive in terms of time and/or stor-
age space. It can be advantageous to have fast, approximate
answers to queries.
In this paper, we present an I/O-ecient technique based
upon a multiresolution wavelet decomposition that yields an
approximate and space-ecient representation of the data
cube, which is one of the core OLAP operators. We build
our compact data cube on the logarithms of the partial sums
of the raw data values of a multidimensional array. We get
excellent approximations for on-line range-sum queries with
limited space usage and computational cost. Multiple data
cubes can be handled simultaneously. Each query can gener-
ally be answered, depending upon the accuracy supported, in
one I/O or a small number of I/Os. Experiments show that
our method performs signicantly better than other approxi-
mation techniques such as histograms and random sampling.
1. Introduction
Computing multiple related group-bys and aggregates is one
of the core operations of On-Line Analytical Processing
(OLAP) applications. Data warehouses often represent data
in the form of several multidimensional databases (MDDB),
also known as data cubes [7].
Consider a very simple multidimensional model, in which
wehave the dimensions
age, income
, and
education level
and
the \measure"
population
. The raw data are stored as a
three-dimensional array
A
. For example, one \cell" of the
array
A
may correspond to (
age
= 30,
income
= $45
K
,
education level
= 5) with a
population
value of 5000, where
Supported in part by Army Research Oce MURI grant
DAAH04{96{1{0013 and by National Science Foundation research
grant CCR{9522047.
y
Contact author. Supported in part by an IBM Graduate Fel-
lowship and by Army Research Oce MURI grantDAAH04{96{
1{0013.
education level 5 corresponds to high school graduate. Thus,
an MDDB can be viewed as a
d
-dimensional array
A
, indexed
by the values of the
d
dimensions (or
functional attributes
),
whose cells contain the values of the
measure attribute
for
the corresponding combination of the functional attributes.
In this paper we shall call this kind of multidimensional ar-
ray
A
the
raw data cube
(or just
data cube
) to distinguish it
from the
extended data cube
and the
partial sum data cube
,
which will be dened later.
Gray et al. [7] propose that the domain of each dimension
be augmented with an additional value for each aggregation
operation, denoted by
all
, to store aggregated values of the
measure attribute among all the cells along that dimension,
and this results in the
extended data cube
. In the ab ove ex-
ample, if we consider the aggregation operation
SUM
, any
range-sum query of (
age, income, education level
), in which
each attribute is either a singleton value or
all
, can be an-
swered by accessing a single cell in the extended data cube.
For example, the total population of 30-year-olds having an
income of $45K is a query specied by (30, $45K,
all
), which
can be answered by one cell access.
An important class of queries on the data cube are the
so-called
range-sum
queries, which are dened by applying
the
SUM
operation over a selected contiguous range in the
domains of some of the attributes [12]. For instance, in the
data cube described above, an example of a range-sum query
is to determine the total population for people with age from
25 to 45 and with income from $50K to $70K. Range-sum
queries are important because several other classes of queries
on the data cube are special cases, such as singleton queries
and slice queries.
Several ecient algorithms for Relational OLAP (RO-
LAP) have been developed to compute the extended data
cube [10, 1]. Zhao et al. [26] propose an array-based algo-
rithm to compute the extended data cube for Multidimen-
sional OLAP (MOLAP) systems. Given appropriate com-
pression techniques, the MOLAP algorithm can be signi-
cantly faster than the ROLAP algorithms.
Previous work on data cube computation has concen-
trated on how to compute the exact data cube. But in reality,
a data warehouse usually has more than one table (in a RO-
LAP system) or data cube (in a MOLAP system), and each
of these tables or cubes contains a very large number of tuples
or entries. A user can query on any element in an extended
data cube computed from any of those relations/cubes in an
OLAP query. Computing all the extended data cubes and
storing and retrieving them on disk becomes infeasible when
the number of underlying relations/cubes is large since no
enough disk storage is available. On the other hand, even
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Date Cube Approximation and Histogram Via Wavelets | CSCI 585 and more Papers Deductive Database Systems in PDF only on Docsity!

Data Cub e Approximation and Histograms via Wavelets

(Extended Abstract)

Je rey Scott Vitter

Center for Geometric Computing and Department of Computer Science Duke University Durham, NC 27708{0129 USA

[email protected]

Min Wangy

Center for Geometric Computing and Department of Computer Science Duke University Durham, NC 27708{0129 USA

[email protected]

Bala Iyer

Database Technology Institute IBM Santa Teresa Lab oratory P.O. Box 49023 San Jose, CA 95161 USA

[email protected]

Abstract

There has recently b een an explosion of interest in the analy- sis of data in data warehouses in the eld of On-Line Analyt- ical Pro cessing (OLAP). Data warehouses can b e extremely large, yet obtaining quick answers to queries is imp ortant. In many situations, obtaining the exact answer to an OLAP query is prohibitively exp ensive in terms of time and/or stor- age space. It can b e advantageous to have fast, approximate answers to queries. In this pap er, we present an I/O-ecient technique based up on a multiresolution wavelet decomp osition that yields an approximate and space-ecient representation of the data cub e, which is one of the core OLAP op erators. We build our compact data cub e on the logarithms of the partial sums of the raw data values of a multidimensional array. We get excellent approximations for on-line range-sum queries with limited space usage and computational cost. Multiple data cub es can b e handled simultaneously. Each query can gener- ally b e answered, dep ending up on the accuracy supp orted, in one I/O or a small numb er of I/Os. Exp eriments show that our metho d p erforms signi cantly b etter than other approxi- mation techniques such as histograms and random sampling.

1. Intro duction

Computing multiple related group-bys and aggregates is one of the core op erations of On-Line Analytical Pro cessing (OLAP) applications. Data warehouses often represent data in the form of several multidimensional databases (MDDB), also known as data cub es [7 ]. Consider a very simple multidimensional mo del, in which we have the dimensions age, income, and education level and the \measure" population. The raw data are stored as a three-dimensional array A. For example, one \cell" of the array A may corresp ond to (age = 30, income = $45K , education level = 5) with a population value of 5000, where

 (^) Supp orted in part by Army Research Oce MURI grant

DAAH04{96{1{0013 and by National Science Foundation research grant CCR{9522047. y (^) Contact author. Supp orted in part by an IBM Graduate Fel-

lowship and by Army Research Oce MURI grant DAAH04{96{ 1{0013.

education level 5 corresp onds to high scho ol graduate. Thus, an MDDB can b e viewed as a d-dimensional array A, indexed by the values of the d dimensions (or functional attributes ), whose cells contain the values of the measure attribute for the corresp onding combination of the functional attributes. In this pap er we shall call this kind of multidimensional ar- ray A the raw data cube (or just data cube ) to distinguish it from the extended data cube and the partial sum data cube, which will b e de ned later. Gray et al. [7 ] prop ose that the domain of each dimension b e augmented with an additional value for each aggregation op eration, denoted by al l , to store aggregated values of the measure attribute among all the cells along that dimension, and this results in the extended data cube. In the ab ove ex- ample, if we consider the aggregation op eration SUM, any range-sum query of (age, income, education level ), in which each attribute is either a singleton value or al l, can b e an- swered by accessing a single cell in the extended data cub e. For example, the total p opulation of 30-year-olds having an income of $45K is a query sp eci ed by (30, $45K, al l ), which can b e answered by one cell access. An imp ortant class of queries on the data cub e are the so-called range-sum queries, which are de ned by applying the SUM op eration over a selected contiguous range in the domains of some of the attributes [12 ]. For instance, in the data cub e describ ed ab ove, an example of a range-sum query is to determine the total p opulation for p eople with age from 25 to 45 and with income from $50K to $70K. Range-sum queries are imp ortant b ecause several other classes of queries on the data cub e are sp ecial cases, such as singleton queries and slice queries. Several ecient algorithms for Relational OLAP (RO- LAP) have b een develop ed to compute the extended data cub e [10 , 1]. Zhao et al. [26 ] prop ose an array-based algo- rithm to compute the extended data cub e for Multidimen- sional OLAP (MOLAP) systems. Given appropriate com- pression techniques, the MOLAP algorithm can b e signi - cantly faster than the ROLAP algorithms. Previous work on data cub e computation has concen- trated on how to compute the exact data cub e. But in reality, a data warehouse usually has more than one table (in a RO- LAP system) or data cub e (in a MOLAP system), and each of these tables or cub es contains a very large numb er of tuples or entries. A user can query on any element in an extended data cub e computed from any of those relations/cub es in an OLAP query. Computing all the extended data cub es and storing and retrieving them on disk b ecomes infeasible when the numb er of underlying relations/cub es is large since no enough disk storage is available. On the other hand, even

with a huge amount of storage space, a range-sum query on a data cub e may need to access all the cells covered by that range so that they can b e summed. In an interactive explo- ration of multiple data cub es, which is a dominant OLAP application area, it is imp erative to have a system with fast resp onse time. Ho et al. [12 ] present an ecient algorithm to sp eed up range-sum queries on a single data cub e. The main idea is to prepro cess the (raw) data cub e A and precompute all the mul- tidimensional partial sums, which can b e represented in what we call the partial sum data cube P. Any range-sum query can b e answered by accessing and computing 2 d

0 entries from the partial sum data cub e, where d^0 is the numb er of dimen- sions for which ranges have b een sp eci ed in the query. For example, in one dimension, the answer to a range-sum query

l 1  D 1  h 1 (1)

(for which d^0 = 1) can b e answered either as

P

l 1 ih 1 A[i] in terms of the extended data cub e or more eciently as

P [h 1 ] P [l 1 1]

in terms of the partial sum data cub e. In two dimensions, the range-sum query

l 1  D 1  h 1 AND l 2  D 2  h 2

(for which d^0 = 2) can b e answered either as

X

l 1 i 1 h 1

X

l 2 i 2 h 2

A[i 1 ; i 2 ]

in terms of the extended data cub e or more eciently as

P [h 1 ; h 2 ] P [l 1 1 ; h 2 ] P [h 1 ; l 2 1] + P [l 1 1 ; l 2 1]

in terms of the partial sum data cub e. If query (1), for which d^0 = 1, is given in a two-dimensional setting, the answer can b e computed either as

P

l 1 i 1 h 1 A[i^1 ;^ al^ l^ ]^ in^ terms^ of^ the extended data cub e or more eciently as

P [h 1 ; jD 2 j 1] P [l 1 1 ; jD 2 j 1]

in terms of the partial sum data cub e. The problem with this partial sum approach is that the partial sums are typically more dense in terms of storage rep- resentation than the original data. The resulting storage re- quired can b e prop ortional to the size of the raw data cub e, which is very large. The appropriate 2 d

0 partial sum values for a given range-sum query might b e stored in di erent disk blo cks in the external memory and accessing them may re- quire up to 2 d

0 disk I/Os, which can b e very exp ensive in terms of I/O for high dimensions. There are a numb er of scenarios in which a user may pre- fer an approximate answer in a few seconds over an exact answer that requires tens of minutes or more to compute. An example is a drill-down query sequence in data mining [11 ]. Another consideration is that the extended data cub e may b e remote and currently unavailable, so that nding an exact answer is not an option, until the data again b ecome avail- able [6 ]. In this pap er, we present an I/O-ecient technique based up on a multiresolution wavelet decomp osition that yields a compact and accurate representation of the data cub e. We build a data cub e on the logarithms of the partial sums of the raw data values. The resulting multidimensional wavelet de- comp osition, after normalization and thresholding to reduce storage cost, provides fast and accurate answers to on-line range-sum queries. The idea of using wavelet techniques in database approx- imation was rst prop osed by Matias, Vitter, and Wang [16 ]. Some of the new contributions in this pap er are the following:

  1. We design I/O ecient algorithm to compute the par- tial sum cub e and multidimensional wavelet decomp o- sition when the raw data cub e is huge and can not t in internal memory. In [16 ], the data arrays considered are low-dimensional and small in size, and thus the I/O eciency of the wavelet decomp osition op eration is not addressed.
  2. We prop ose a new thresholding metho d based on the logarithm transform that dramatically reduces the rel- ative error and even the absolute error in the approxi- mation of high-dimensional data.
  3. By applying the new thresholding metho d in build- ing wavelet-based histograms as prop osed in [16 ], we can achieve much b etter accuracy even for the low- dimensional data, esp ecially when reducing relative er- rors in the approximation b ecomes imp ortant. Our metho d is designed to accommo date the approxima- tion of several data cub es. Each query can generally b e an- swered, dep ending up on the accuracy supp orted, in one I/O or a small numb er of I/Os. For example, we get a very go o d approximation of the partial sum data cub e by storing one disk blo ck's worth of wavelet co ecients. In such a case, any set of queries on that data cub e can b e answered collectively with a total of only one I/O. The accuracy of the resulting ap- proximation, as a function of the storage used, is noticeably b etter than those of other approximation techniques based up on histograms and random sampling. In the next section, we discuss the construction of the approximate partial sum data cub e and the analysis of I/O p erformance. The I/O complexity is often O (N =B ), which is b est p ossible, and is never more than the I/O b ound for sort- ing, namely, O ( NB log (^) M =BNB ), where M is the size of internal memory and B is the disk blo ck size [25 ]. The on-line query phase, which requires only a constant numb er of I/Os in total for an arbitrary numb er of queries, is explained and analyzed in Section 3. Our exp erimental results in Section 4 demon- strate a comp etitive advantage of our wavelet technique over histograms and random sampling in many cases, while while it is comparable to the histogram metho d for other typ es of queries.

2. Our Compact Data Cub e Construction

Algorithm

We adopt the notations in [12 ] to formulate the problem. Let D = fD 1 ; D 2 ; : : : ; Dd g denote the set of dimensions, where each dimension corresp onds to a functional attribute. We represent the d-dimensional (raw) data cub e A by a d- dimensional array of size jD 1 j  jD 2 j      jDd j, where jDi j is the size of dimension Di. We assume without loss of gen- erality that each array has starting index 0. For convenience, we call each array element a cel l. We let N =

Q

1 id jDi^ j denote the total size (numb er of cells) of data cub e A. The problem of computing a range-sum query in a d- dimensional data cub e can b e formulated as follows:

S um(l 1 : h 1 ; : : : ; ld : hd ) =

X

l 1 i 1 h 1

  

X

ld id hd

A[i 1 ; : : : ; id ]:

The partial sum data cub e P is a d-dimensional array of size jD 1 j  jD 2 j      jDd j (which is the same as the size of A). Its cells are de ned as

P [x 1 ; : : : ; xn ] = S um(0 : x 1 ; : : : ; 0 : xd )

=

X

0 i 1 x 1

  

X

0 id xd

A[i 1 ; : : : ; id ]:

cub e chunks in d dimensions to b e the ordering of the chunks that changes most rapidly along the rightmost dimension Did , next most rapidly along dimension Did 1 , and so on. Di er- ent dimension orders corresp ond to di erent orders of access- ing the data cub e chunks. In the example in Figure 1, the chunks are ordered with resp ect to one another according to the dimension order (D 3 ; D 2 ; D 1 ).^1

Theorem 2 In the case of general internal memory size M , we consider a data cube A in chunked form of size N =

Q

1 id jDi^ j,^ where^ jDi^ j^ is^ the^ size^ of^ dimension^ Di^. The I/O complexity of computing the partial sum data cube P is O ( NB log (^) M =BNB ), where B is the disk block size.

Proof Sketch : We partition the d dimensions into g groups so that for the ith group Gi = fDi 1 , Di 2 , : : : ; Diki g, we have

Y

1 j ki

jDij j

Y

1 ld Dl 2 =Gi

cl  M : (2)

If (2) cannot b e met, that is, if the size of dimension Di 1 satis es jDi 1 j

Q

l 6 =i 1 cl^ >^ M^ ,^ we^ put^ Di^1 into^ a^ singleton^ group containing only itself. To compute the partial sums, at the ith pass of our al- gorithm, we read the chunks computed in the previous pass in dimension order (; : : : ; ; Di 1 ; Di 2 ; : : : ; Diki ), where  de- notes the dimensions that are not in Gi. If the ith group Gi satis es (2), we successively read in a ki -dimensional hyp er- plane of chunks along dimensions Di 1 , Di 2 ,... , Diki (as de ned in Figure 1). The size of each such ki -dimensional hyp erplane of chunks is given by the left-hand size of (2), and thus it ts in internal memory. For each hyp erplane of chunks, after it is brought into internal memory, we compute the partial sums along each of those dimensions Di 1 ; : : : ; Diki and write the resulting hyp erplane of chunks back to disk, chunk by chunk. For a singleton group Gi , each hyp erplane of chunks along dimension Di 1 (which b ecause of the one-dimensionality is a \line" of chunks) may not t in internal memory. How- ever, b ecause of its single dimension, we can read each line of chunks along dimension Di 1 and compute its partial sums in one pass using O (N =B ) I/Os. When we are done with the g th pass, we have the partial sum data cub e P. By algebraic manipulation we can show that g = O (log (^) M =BNB ). The I/O cost of each of the g passes

is O ( NB ). The desired time b ound follows.

All choices of the chunk sizes ci yield the upp er b ound result of Theorem 2. But some choices can do much b etter than others. Let us consider the example B = M =2, N = 1 2 M^

(^3) , d = (log M ) + 1, jDi j = 2 (for 1  i  d 2), and

jDd 1 j = jDd j = M. The smart choice ci = 2 (for 1  i  d 2) and cd 1 = cd = 1 yields g = 3, and thus the algorithm runs in O (N =B ) I/Os, even though Theorem 1 do es not apply. However, the alternate choice ci = 1 (for 1  i  d 1) and cd = M = 2 = B yields g = d = (log M ) + 1, and thus the algorithm runs in O ( NB log M ) I/Os.

2.2. Wavelet Decomp osition of the Partial Sum Data Cub e P

Wavelets are a mathematical to ol for the hierarchical decom- p osition of functions. Wavelets represent a function in terms of a coarse overall shap e, plus details that range from coarse to ne. Regardless of whether the function of interest is an

(^1) The de nition of dimension order in our pap er corresp onds

to the C programming language array declaration syntax and is di erent from that of [26].

image, a curve, or a surface, wavelets o er an elegant tech- nique for representing the various levels of detail of the func- tion in a space-ecient manner. The raw data cub e A is often sparse in terms of the num- b er of nonzero elements, but the partial sum data cub e P tends to b e dense. For that reason we con ne ourselves in this pap er to wavelet decomp ositions of dense data cub es, esp ecially since the I/O pro cessing is very ecient in terms of the dense representation. (Some p ossible compression ap- proaches for computing the wavelet decomp osition are men- tioned in Section 5 and are the sub ject of continuing work.) To start the wavelet decomp osition pro cedure, rst we need to cho ose the wavelet basis functions. Haar wavelets are conceptually the simplest wavelet basis functions, and for purp oses of exp osition in this pap er, we fo cus our discussion on Haar wavelets. They are fastest to compute and easiest to implement. To illustrate how Haar wavelets work, we start with a simple example. A detailed treatment of wavelets can b e found in any standard reference on the sub ject (e.g., [13 , 21 ]). Supp ose we have a one-dimensional \signal":

[2, 2, 7, 11] :

We p erform a wavelet transform on it. We rst average the signal values, pairwise, to get the new lower-resolution signal with values [2, 9] : That is, the rst two values in the original signal (2 and 2) average to 2, and the second two values 7 and 11 average to 9. Clearly, some information is lost in this averaging pro cess. To recover the original signal from the two averaged values, we need to store some detail coecients, which capture the miss- ing information. Haar wavelets store the pairwise di erences of the original values as detail co ecients. In the ab ove ex- ample, the two detail co ecients are 2 2 = 0 and 11 7 = 4. It is easy to see that the original values can b e recovered from the averages and di erences. We have succeeded in decomp osing the original signal into a lower-resolution version of half the numb er of entries and a corresp onding set of detail co ecients. By rep eating this pro cess recursively on the averages, we get the full decomp o- sition:

Resolution Averages Detail Co ecients 4 [2, 2, 7, 11] 2 [2, 9] [0, 4] 1 [5 12 ] [7] We de ne the wavelet transform (also called wavelet decom- position ) of the original four-value signal to b e the single co- ecient representing the overall average of the original signal, followed by the detail co ecients in the order of increasing resolution. Thus, for the one-dimensional Haar basis, the wavelet transform of our original signal is given by

[5 12 , 7, 0, 4] : (3)

The individual entries are called the wavelet coecients. The wavelet decomp osition is very ecient computationally, re- quiring only O (N ) time and O (N =B ) I/Os to compute for a signal of N values. No information has b een gained or lost by this pro cess. The original signal has four values, and so do es the trans- form. Given the transform, we can reconstruct the exact signal by recursively adding and subtracting one half of the detail co ecients from the next-lower resolution.

For compression reasons, the detail co ecients at each level of the recursion are often normalized; the co ecients at the lower resolutions are weighted more heavily than the co ecients at the higher resolutions. One advantage of the normalized wavelet transform is that in many cases a large numb er of the detail co ecients turn out to b e very small in magnitude. Truncating these small co ecients from the representation (i.e., replacing each one by 0) intro duces only small errors in the reconstructed signal. We can approximate the original signal e ectively by keeping only the most signif- icant co ecients. The one-dimensional wavelet decomp osition and recon- struction pro cedure can b e extended naturally to the multi- dimensional case. One way to do a multidimensional wavelet decomp osition is by a series of one-dimensional decomp osi- tions. For example, in the two-dimensional case, we rst apply the one-dimensional wavelet transform to each row of the data. Next, we treat these transformed rows as if they were themselves the original data, and we apply the one- dimensional transform to each column. In terms of the I/O involved, the pro cedure for doing the multidimensional wavelet decomp osition on the partial sum cub e P is similar to that of computing A from P , since they b oth p erform certain kinds of op erations along each dimen- sion of a d-dimensional array:

Theorem 3 Consider a multidimensional partial sum data cube P having size N =

Q

1 id jDi^ j,^ where^ jDi^ j^ is^ the^ size of dimension Di and jD 1 j  jD 2 j      jDd j. The total amount of internal memory required to compute the wavelet decomposition of P in one linear scan of P is O (

Q

1 id 1 jDi^ j). Theorem 4 In the case of general internal memory size M , we consider a multidimensional partial sum data cube P in chunked form of size N =

Q

1 id jDi^ j,^ where^ jDi^ j^ is^ the^ size of dimension Di. The I/O complexity of computing the mul- tidimensional wavelet decomposition of P is O ( NB log (^) M =BNB ), where B is the disk block size.

The pro ofs of the ab ove theorems are similar to those of Theorem 1 and Theorem 2, resp ectively, except that we p erform a one-dimensional wavelet decomp osition instead of a one-dimensional partial sum op eration along each dimension.

2.3. Thresholding and Error Measures

Our motivation in this pap er is a compact, yet accurate rep- resentation of the partial sum data cub e. Given the storage limitation for the compact data cub e, we can only \keep" a certain numb er of the N wavelet co ecients. Let C de- note the numb er of wavelet co ecients that we have ro om to keep; the remaining wavelet co ecients are implicitly set to 0. Typically we have C  N. The goal of thresholding is to determine which are the \b est" C co ecients to keep, so as to minimize the error of approximation. We can measure the error of approximation in several

ways. Let vi b e the actual answer of a query qi and let vbi b e

the approximate answer. We use the following four di erent error measures for the error ei of approximating query qi :

Notation De nition

absolute error eabs i jvi vbi j

relative error erel i

jvi vbi j

maxf 1 ; vi g modi ed relative error em i^ rel

jvi vbi j

maxf 1 ; minfvi ; vbi gg

combined error ecom i b minf  eabs i ;  erel i g

The parameters and are p ositive constants.

Our de nition of relative error is slightly di erent from the traditional one, which is not de ned when vi = 0. The mo di ed relative error treats over-approximation and under- approximation in a uniform way. The combined error re ects the imp ortance of having either a go o d relative error or a go o d absolute error for each approximation. For example, for very small vi it may b e go o d enough if the absolute error is small even if the relative error is large, and for large vi the absolute error may not b e as meaningful as the relative error. Once we cho ose which of the ab ove measures to represent the errors of the individual queries, we need to cho ose a norm by which to measure the error of a collection of queries. Let e = (e 1 , e 2 ,... , eQ ) b e the vector of errors over a sequence of Q queries. We assume that one of the ab ove four error measures is used for each of the individual query errors ei. For example, for absolute error, we can write ei = eabs i. We de ne the overall error for the Q queries by one of the following error measures:

Notation De nition

1-norm average error kek 1

Q

X

1 iQ

ei

2-norm average error kek 2

s

Q

X

1 iQ

ei 2

in nity-norm error kek 1 max 1 iQ

fei g

These error measures are sp ecial cases of the p-norm av- erage error, for p > 0:

kekp =

Q

X

1 iQ

ei p

 1 =p

The rst step in thresholding is normalizing the co e- cients in a certain way (which corresp onds to using a par- ticular basis, such as an orthonormal basis, for example). It is well-known that thresholding by cho osing the C largest (in absolute value) wavelet co ecients after normalization is provably optimal in minimizing the 2-norm of the absolute er- rors, among all p ossible choices of C nonzero co ecients, as- suming that the wavelet basis functions are orthonormal [21 ]. With prop er normalization, which we use, the Haar basis is orthonormal. As a result, normalization and threshold- ing p erform well in practice on other norms of absolute er- ror, such as the p-norms, for p > 0. There are no known computationally ecient metho ds for minimizing these other norms, although some approximation techniques have b een studied [5 ]. In many circumstances, we want to minimize the relative error of our approximation. We use the following metho d to convert a metho d for achieving go o d absolute error into a metho d for achieving go o d relative error: We take the natural logarithm of each element in P b efore we do the wavelet de- comp osition, and we apply the inverse (i.e., exp onentiation) after reconstruction in the on-line phase. The intuition for this prepro cessing is based on the following fact: If we denote the function we want to approximate by f (x), where x varies over some domain, let us consider its logarithm

g (x) = ln f (x):

If we approximate the function g using wavelets with normal- ization and thresholding, then we can exp ect that the result-

ing approximation bg has small absolute error. In particular

we have

bg (x) = g (x) + (x);

As we discussed in Section 2.3, combining a logarithm transformation with the approximation technique can b e ef- fective in reducing the relative error of the approximation. Our exp eriments also test a mo di ed MaxDi histogram that uses the logarithm transform. The storage required for each of the b buckets in the his- togram is three numb ers: one to store the index of the front corner of the bucket (w.r.t. the linear order of the cells), an- other to store the index of the far corner of the bucket, and a third to store the (average) value asso ciated with the bucket. (Po osala and Ioannidis [18 ] use d + 1 numb ers to represent each bucket, but we instead use just three numb ers p er bucket by taking advantage of the one-dimensional order of the cells, as shown in Figure 1.)

4.1.2. Random Sampling Several random sampling techniques, in which a large set of data is represented by a smaller random sample of the data, have b een develop ed for database optimization [8 , 9, 15, 14 ]. We can approximate the raw data cub e by taking a random sample of a certain size from the nonzero cells of the raw data cub e. When a range-sum query is presented in the on- line phase, the query is evaluated against the sample, and the approximate answer is extrap olated in the obvious way: If the answer to the query using a sample of size t is s, the approximate answer that will b e rep orted is sT =t, where T is the total numb er of the nonzero cells in the raw data cub e. To store the samples as a compact data cub e, we need to keep the indices of the sampled cells in the linear order, together with the value of the cell. Thus, storing a random sample of size t requires 2 t numb ers.

4.2. Data Description

In [16 ], a series of exp erimental results on selectivity estima- tion in low dimensions is presented that compares the accu- racy of the wavelet-based approximation technique with that of histograms and random sampling. The data used in [16 ] are TPC-D [22 ] b enchmark data and some synthetic data sets generated using Zipf distribution. Those same data sets are used in our exp eriments for approximating low-dimensional data. We apply our new thresholding metho d on the wavelet- based histogram technique to show the signi cant improve- ment in accuracy. In many real OLAP applications, the data have high di- mension and the correlations among the functional attributes and the measure are intricate and do not match arti cial data mo dels. To make our exp erimental results meaningful, we p erformed our exp eriments using real-world data as well as synthetic data. For brevity in this pap er, we rep ort our high-dimensional results on only the real-world data. Our real-world data are obtained from the U.S. Cen- sus Bureau databases using their Data Extraction System (DES) [4 ]. Our data source is the Current Population Sur- vey (CPS) and our extracted le is the March Question- naire Supplement{Person Data File. This le contains 372 attributes from which we chose 11. Our measure attribute is income and the 10 functional attributes are age, marital status, sex, education attainment, race, origin, family type, detailed household summary, age group, and class of worker. In the original data le, all the attributes are already pre- pro cessed and have a relatively small dimension size; that is, the domain of each dimension Di is f 0 ; 1 ; : : : ; jDi j 1 g, for some small integer jDi j. Although the dimension sizes are generally small, the high dimensionality results in a raw data cub e with more than 16 million cells. The density of the raw data cub e is ab out 0 :001; there are 15,985 nonzero elements.

In this setting we can imagine that several data cub es are ap- proximated, and each data cub e must b e approximated using very little space.

4.3. Exp erimental Comparisons of Approximation We compare the e ectiveness of our compact data cub e via wavelets with those of MaxDi histogram and random sam- pling. Di erent techniques need to store di erent typ es of information. We saw earlier in Sections 2.3 and 4.1 that our wavelet technique needs to store 2 C numb ers to represent C co ecients, MaxDi needs 3 b numb ers to represent b buckets, and random sampling needs 2 t numb ers to store a sample of size t. In our exp eriments, all metho ds are allowed the same amount of storage. We varied the allowed storage from 400 four-byte numb ers to 2000 four-byte numb ers. This small storage space corresp onds to the practice in OLAP applica- tions of handling several data cub es using a limited amount of storage space. The approximate data cub es can b e accessed in the on-line phase in a single I/O. For example, a space usage of 800 numb ers corresp onds to keeping C = 400 wavelet co ecients for our wavelet-based approximation, using b = 267 buckets for the MaxDi his- togram, and maintaining a random sample of size t = 400. We measure the errors of the various approximation tech- niques in our exp eriments using ve typ es of query predicates. In each dimension, the range is indep endently and uniformly generated according to the sp eci ed typ e: A: fDi  hi j hi 2 f 0 ; 1 ; : : : ; jDi j 1 gg. B: fli  Di  hi j li ; hi 2 f 0 ; 1 ; : : : ; jDi j 1 g, li < hi g. C: fli  Di  hi j li ; hi 2 f 0 ; 1 ; : : : ; jDi j 1 g, hi = li + g, where  is a p ositive integer constant. D: fDi = b j b 2 f 0 ; 1 ; : : : ; jDi j 1 gg. E: fDi = jDi j 1 g. We applied di erent combinations of these predicates on the set of 10 attributes. Our metho d is more accurate in ap- proximating most typ es of on-line queries than the histogram and random sampling techniques, while it is comparable to the histogram metho d and b etter than random sampling for other typ es of queries. We present the results from one exp er- iment of Typ e A queries. Table 1 gives the detailed compar- isons using our wavelet technique, the MaxDi histograms, and random sampling for a storage size of 800 four-byte num- b ers. Figure 2 plots the e ect of di erent storage sizes. For random sampling, the errors are the averages over several di erent runs. From Table 1 and Figure 2, we can see that our compact wavelet-based data cub e is more accurate in approximating on-line queries than the histogram and sampling techniques. As an example, let us consider a range-sum query on income whose exact answer is 10K (dollars). Our compact data cub e with storage size 800 may give an answer of 12.2K (with rel- ative error 22%). The average relative error can typically b e reduced to ab out 13% if we increase the storage space from 800 numb ers to 2000 numb ers. In [16 ], the wavelet-based histogram metho d was prop osed to approximate low-dimensional data for selectivity estima- tion. The wavelet-based histograms p erformed b est overall in comparison with MaxDi histograms and random sampling. In this pap er we demonstrate the e ectiveness of our new metho d against that of the previous wavelet-based histograms in [16 ]. We call our new histograms new wavelet-based his- tograms to distinguish them from the old wavelet-based his- tograms in [16 ]. The relative e ectiveness of the two metho ds is constant over a wide variety of low-dimensional data sets

Error Norm Wavelets MaxDi Modi ed MaxDi Random Sampling keabs^ k 1 =S 0.39% 0.84% 2.87% 1.6% keabs^ k 2 =S 1.37% 1.92% 84.5% 4.5% kerel^ k 1 22% 6400% 580% 90% kem^ rel^ k 1 27% 6400% 1180% 5000% kecomb^ k 1 , = 1 ; = 100 12 690 98 70 kecomb^ k 2 , = 1 ; = 100 25 2361 155 100 kecomb^ k 1 , = 1 ; = 10 1.7 232 22 10 kecomb^ k 2 , = 1 ; = 10 3.1 904 54 10

Table 1: Errors of various metho ds with storage size 800 on queries of Typ e A. The absolute errors are normalized by the largest value S = 907 ; 589 in the multidimensional partial sum data cub e.

500 1000 1500 2000 Storage Size (# of stored values)

0

1

2

3

1-norm average absolute error divided by S (%)

(^) Modified MaxDiff Random Sampling MaxDiff Wavelets

(a) 1-norm average absolute error

500 1000 1500 2000 Storage Size (# of stored values)

0

2

4

6

8

10

2-norm average absolute error divided by S (%)

(^) Modified MaxDiff Random Sampling MaxDiff Wavelets

(b) 2-norm average absolute error

500 1000 1500 2000 Storage Size (# of stored values)

0

2000

4000

6000

8000

10000

1-norm average relative error (%)

MaxDiff Modified MaxDiff Random Sampling Wavelets

(c) 1-norm average relative error

500 1000 1500 2000 Storage Size (# of stored values)

0

2000

4000

6000

8000

10000

1-norm average modified relative error (%)

MaxDiff Random Sampling Modified MaxDiff Wavelets

(d) 1-norm average mo di ed rela- tive error

500 1000 1500 2000 Storage Size (# of stored values)

0

200

400

600

800

1000

1-norm average combined error

MaxDiff Modified MaxDiff Random Sampling Wavelets

(e) 1-norm average combined er- ror, = 1 :0, = 100

500 1000 1500 2000 Storage Size (# of stored values)

0

1000

2000

3000

2-norm average combined error

MaxDiff Modified MaxDiff Random Sampling Wavelets

(f ) 2-norm average combined er- ror, = 1 :0, = 100 Figure 2: E ect of storage space for various metho ds on range-sum queries of Typ e A.

that we used. We present results for Typ e A queries using the synthetic data describ ed in [16 ]. Table 2 shows various typ es of errors for four data sets. In the exp eriments, all data sets are generated using Zipf distribution with di erent Zipf pa- rameters. Data sets A and B are one-dimensional data. Their value set size is n = 500, the domain size is N = 4096, and the relation size is T = 105. We keep 21 wavelets co ecients in the exp eriments. Data sets C and D are two-dimensional data. Their value set size is n = 2500, the domain size is N = 65536, and the relation size is T = 106. We keep 70 wavelets co ecients in the exp eriments. The new metho d dramatically reduces the relative error and combined errors of the approximation, while keeping other error measurements roughly the same.

5. Conclusions

In this pap er, we present an I/O-ecient technique based up on a multiresolution wavelet decomp osition that yields an approximate and space-ecient representation of the data cub e. We build our compact data cub e on the logarithms of the partial sums of the raw data values of a multidimensional array. We get excellent approximations for on-line range- sum queries with limited space usage and computational cost. Our new thresholding metho d of taking the logarithmic trans- form also provides signi cant improvement for wavelet-based histograms used in selectivity estimation of low-dimensional data. One drawback of our current approach is that the con-