Aggregation queries are performed by first identifying outlier values,
aggregating the outlier values, and sampling the remaining data after
pruning the outlier values. The sampled data is extrapolated and added to
the aggregated outlier values to provide an estimate for each aggregation
query. Outlier values are identified by selecting values outside of a
selected sliding window of data having the lowest variance. An index is
created for the outlier values. The outlier data is removed from the
window of data, and separately aggregated. The remaining data without the
outliers is then sampled in one of many known ways to provide a
statistically relevant sample that is then aggregated and extrapolated to
provide an estimate for the remaining data. This sampled estimate is
combined with the outlier aggregate to form an estimate for the entire
set of data. Further methods involve the use of weighted sampling and
weighted selection of outlier values for low selectivity queries, or
queries having group by.