Skip to content

rqe-optimizer: exact sum/min-max/increase accumulators, CountSketch+heap and UnivMon top-k - #144

Merged
milindsrivastava1997 merged 4 commits into
mainfrom
rqe-optimizer-capabilities
Oct 6, 2026
Merged

milindsrivastava1997 merged 4 commits into
mainfrom
rqe-optimizer-capabilities

Conversation

@milindsrivastava1997

@milindsrivastava1997 milindsrivastava1997 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Updates the query types the optimizer knows about and the sketches it can pick for them.

Before / after

Query type Before After
Frequency CMS, CountSketch removed
Sum / count over time — exact sum
Min over time — exact min
Max over time — exact max
Rate / increase — exact increase
Quantile KLL, DDSketch KLL, DDSketch
Cardinality HLL, UnivMon HLL, UnivMon
Top-k CMS + heap CMS + heap, CountSketch + heap, UnivMon

Changes

  • Removed the "frequency" query type.
  • Added four query types, each answered exactly instead of with a sketch:
    • sum / count over time → exact-sum
    • min over time → exact-min
    • max over time → exact-max
    • rate / increase → exact-increase
  • These exact versions copy how ASAPQuery stores and merges the same data, and track every group in one structure.
  • Added two new options for top-k queries: CountSketch with a heap, and UnivMon.
  • Fixed costs for the exact versions: they are now recorded per group, so the optimizer doesn't count each group twice.
  • Updated the cost export script to measure the new options. It hasn't been run yet.
  • Added test data for rate / increase (configs/datagen/counter_columns.yaml): values that only go up, like real counters. It uses the data generator's existing "monotonic increase" setting, so the data generator code itself is unchanged.

Files changed in aqpbm-cli and aqpbm-core

  • aqpbm-cli/src/rows/exact.rs (new): runs the benchmarks for the four exact versions and the two new top-k options.
  • aqpbm-cli/src/rows/materialise.rs: can now read grouped data with each label kept separate, instead of joined into one string.
  • aqpbm-cli/src/rows/mod.rs: connects the six new benchmark names to their code.
  • aqpbm-core/src/accuracy/aggregate.rs (new): computes the correct sum / min / max / increase per group and compares the benchmarked answers against it.
  • aqpbm-core/src/accuracy/mod.rs: registers the new file above.
  • aqpbm-core/src/accuracy/subpopulation/mod.rs: lets the new file reuse an existing helper that reads each row's group.
  • aqpbm-core/src/atomic_costs.rs: for the exact versions, divides memory and merge cost by the number of groups so costs are per group.

Testing

  • The exact versions give the correct answer for every group, both on their own and after combining 16 pieces.
  • Added unit tests for the new code.

Not included

Part of #132.

🤖 Generated with Claude Code

Replace the optimizer's Freq capability with SumOrCount, MinOrMax and
RateOrIncrease, served by exact multi-subpopulation accumulators that
match ASAPQuery's Multiple{Sum,MinMax,Increase}Accumulator. Add
CountSketch+heap and UnivMon as TopK candidates. Price grouped
accumulators per group so the optimizer's card(group-by) multiply
counts each group once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
milindsrivastava1997 and others added 3 commits October 5, 2026 14:41
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
exact-max only tracked the maximum, so min_over_time queries had no
candidate. Min and Max are now separate capabilities served by
exact-min and exact-max (ASAPQuery's MinMax sub-types), so a min query
never lands on or shares a max accumulator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zzylol

zzylol commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

is rate / increase both the same increase function? I remember they are different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants