
Approximate Frequency Counts over Data Streams
Gurmeet Singh Manku
Stanford University
Rajeev Motwani
Stanford University
Abstract
We present algorithms for computing frequency
counts exceeding a user-specified threshold over
data streams. Our algorithms are simple and have
provably small memory footprints. Although the
output is approximate, the error is guaranteed not
to exceed a user-specified parameter. Our algo-
rithms can easily be deployed for streams of single-
ton items like those found in IP network monitor-
ing. We can also handle streams of variable sized
sets of items exemplified by a sequence of mar-
ket basket transactions at a retail store. For such
streams, we describe an optimized implementation
to compute frequent itemsets in a single pass.
1 Introduction
In several emerging applications, data takes the form
of continuous data streams, as opposed to finite stored
datasets. Examples include stock tickers, network traffic
measurements, web-server logs, click streams, data feeds
from sensor networks, and telecom call records. Stream
processing differs from computation over traditional stored
datasets in two important aspects: (a) the sheer volume of
a stream over its lifetime could be huge, and (b) queries re-
quire timely answers; response times should be small. As
a consequence, it is not possible to store the stream in its
entirety on secondary storage and scan it when a query ar-
rives. This motivates the design for summary data struc-
tures with small memory footprints that can support both
one-time and continuous queries.
Supported by NSF Grant IIS-0118173 and Stanford Graduate
Fellowship
Supported by NSF Grant IIS-0118173, an Okawa Foundation Re-
search Grant, and grants from Microsoft and Veritas.
Permission to copy without fee all or part of this material is granted pro-
vided that the copies are not made or distributed for direct commercial
advantage, the VLDB copyright notice and the title of the publication and
its date appear, and notice is given that copying is by permission of the
Very Large Data Base Endowment. To copy otherwise, or to republish,
requires a fee and/or special permission from the Endowment.
Proceedings of the 28th VLDB Conference,
Hong Kong, China, 2002
An aggregate query that is widely applicable is
SELECT R.EventType, COUNT(*) FROM R GROUP BY
R.EventType, where relation Rmodels a stream of
events with attribute R.EventType denoting the type of
event. In several applications, groups with very low
frequencies are uninteresting; the user is interested in
only those groups whose frequency exceeds a certain
threshold, usually expressed as a percentage of the size
of the relation seen so far. The modified query then
is SELECT R.EventType, COUNT(*) FROM R GROUP
BY R.EventType HAVING COUNT(*) > s |R| where
sis a user-specified percentage and |R| is the length of
stream seen so far.
A related aggregate query is over an input stream rela-
tion whose tuples are sets of items rather than individual
items. The goal is to compute all subsets of items, here-
after called itemsets, which occur in at least a fraction
of
the stream seen so far. This is far more challenging than
counting singleton tuples.
1.1 Motivating Examples
Here are four problems drawn from databases, data min-
ing, and computer networks, where frequency counts ex-
ceeding a user-specified threshold are computed.
1. An iceberg query [FSGM
98] performs an aggregate
function over an attribute (or a set of attributes) of a
relation and eliminates those aggregate values that are
below some user-specified threshold.
2. Association rules [AS94] over a dataset consisting of
sets of items, require computation of frequent itemsets,
where an itemset is frequent if it occurs in at least a
user-specified fraction of the dataset.
3. Iceberg datacubes [BR99, HPDW01] compute only
those Group By’s of a CUBE operator whose aggre-
gate frequency exceeds a user-specified threshold.
4. Traffic measurement and accounting of IP packets re-
quires identification of flows that exceed a certain frac-
tion of total traffic [EV01].
Existing algorithms for iceberg queries, association
rules, and iceberg cubes have been optimized for finite
stored data. They compute exact results, attempting to
minimize the number of passes they make over the en-
tire dataset. The best algorithms take two passes. When