Skip to content

Scoutdb aggregation and filter pushdown optimizations - #1

Draft
bendischinger wants to merge 13 commits into
mainfrom
scoutdb
Draft

Scoutdb aggregation and filter pushdown optimizations#1
bendischinger wants to merge 13 commits into
mainfrom
scoutdb

Conversation

@bendischinger

Copy link
Copy Markdown
Collaborator

Just putting this out here to get some eyes on it for now.

This commit enhances the pushdown optimization logic to better handle
filter conditions and improve query performance.
Add support for pushing down aggregation operations to storage engines
for improved query performance. This includes partition-aware aggregation
handling and integration with the query planner.
Add a max_join_build_rows session variable (Uint64, dynamic, default 0=unlimited)
and instrument hashLookupGeneratingIter to abort with
ErrHashLookupBuildExceededMemory when the build side exceeds the cap. Also OR-in
the MemoryManager HasAvailable backstop so a runaway join returns an error
instead of OOMing the process.
partitionGroupedAggregationIter.computeAll accumulates all merged groups
into an unbounded map. Check ctx.Memory.HasAvailable() each time a new
group is added and return ErrNoMemoryAvailable when the MemoryManager
reports it is exhausted, so a high-cardinality group-by returns an error
instead of OOMing the process. Mirrors the hash-join build-side backstop.
Allow COUNT/SUM/MIN/MAX/AVG over a scalar expression argument (e.g.
SUM(CASE WHEN size < 1024 THEN 1 ELSE 0 END)) to be pushed down to
AggregableTable integrators, for both ungrouped and grouped (GROUP BY)
queries, not just bare columns.

- Add optional Expr field to sql.ColumnAggregation
- Analyzer: extract expression aggregations for the ungrouped, COUNT,
  and grouped paths; require the expr to reference at least one table
  column and reject nested aggregates/subqueries/aliases (SUM/AVG still
  require a safe numeric type). COUNT(*)/COUNT(1) keep their existing
  bare-count representation
- PartitionAggregation/PartitionGroupedAggregation: resolve type/display
  from Expr when present
- memory table: evaluate Expr per row, remapping GetField indices to the
  full schema, for both ungrouped and grouped compute paths
- Test ungrouped, COUNT, and grouped conditional aggregation pushdown
  across multiple partitions
Introduce a storage-driven join pushdown feature that lets a table
evaluate an INNER equi-join against a co-partitioned table at the
partition level, mirroring the existing aggregation pushdown.

- sql: add JoinableTable interface + JoinPushdown spec (tables.go),
  PartitionJoin plan node, and its rowexec builder
- analyzer: add pushdownPartitionJoins rule (runs before join
  physicalization) that collapses Filter-over-InnerJoin and bare
  InnerJoin into a PartitionJoin, pushing qualifying WHERE predicates
  into the table; unwrap PartitionJoin in getResolvedTableForAgg so
  aggregation composes over a pushed-down join
- memory: implement JoinableTable (opt-in, off by default) with a
  partition-level hash join; store the opt-in flag in TableData so it
  survives session table reconstruction
- plan printer: show On(...), Right(...), and pushed Filters(...)
- docs: add JOINPUSHDOWN.md, cross-reference from AGGPUSHDOWN.md
- tests: TestPartitionJoinPushdown and
  TestPartitionJoinAggregationComposition
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.

1 participant