Skip to content

features: run single-shot multi-query sub-queries concurrently#558

Merged
azahnen merged 4 commits into
masterfrom
multi-feature-query-parallel-subqueries
Jul 10, 2026
Merged

features: run single-shot multi-query sub-queries concurrently#558
azahnen merged 4 commits into
masterfrom
multi-feature-query-parallel-subqueries

Conversation

@cportele

Copy link
Copy Markdown
Contributor

Depends on #555.
Depends on ldproxy/xtraplatform#428.

Single-shot multi-queries read every sub-query in one pass with no cross-sub-query dependency, so the sub-queries can now execute concurrently while their rows are still emitted in sub-query order:

  • the value phase uses an order-preserving concurrent flat-map over the sub-queries (Transformer.flatMapConcurrent);
  • each sub-query's value queries are subscribed on a worker thread (SqlQueryOptions.isParallel) so the blocking JDBC reads actually overlap instead of running on a single thread;
  • a shared connection-budget semaphore (sized to the pool) bounds the connections held by the in-flight sub-queries and acquires each sub-query's permits as a block, so concurrent requests cannot deadlock by each holding part of the pool.

Paged and single-feature reads keep the serial path. Requires the matching xtraplatform-core operators flatMapConcurrent and guarded.

cportele added 2 commits June 28, 2026 12:09
A multi-feature query can run single-shot - one pass per (sub-query, table), with no meta query, no chunking and no key-range window - using a server-side cursor to keep memory bounded; an optional per-sub-query maximum bounds each sub-query. When paged, numberMatched is computed across all sub-queries (the invariant total) while value queries are executed only for the sub-queries needed for the page.
Single-shot multi-queries read every sub-query in one pass with no
cross-sub-query dependency, so the sub-queries can now execute concurrently
while their rows are still emitted in sub-query order:

- the value phase uses an order-preserving concurrent flat-map over the
  sub-queries (Transformer.flatMapConcurrent);
- each sub-query's value queries are subscribed on a worker thread
  (SqlQueryOptions.isParallel) so the blocking JDBC reads actually overlap
  instead of running on a single thread;
- a shared connection-budget semaphore (sized to the pool) bounds the
  connections held by the in-flight sub-queries and acquires each sub-query's
  permits as a block, so concurrent requests cannot deadlock by each holding
  part of the pool.

Paged and single-feature reads keep the serial path. Requires the matching
xtraplatform-core operators flatMapConcurrent and guarded.
@cportele cportele requested a review from azahnen as a code owner June 29, 2026 11:14
Base automatically changed from multi-feature-query-scopes to master July 10, 2026 09:51
@azahnen azahnen enabled auto-merge (squash) July 10, 2026 10:56
@azahnen azahnen merged commit fabaf84 into master Jul 10, 2026
3 checks passed
@azahnen azahnen deleted the multi-feature-query-parallel-subqueries branch July 10, 2026 11:00
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