An LLM call in a semantic data processing system is expensive enough to dominate query cost, yet slow enough to hide a CPU-side learner's update behind its round-trip. In production, LLM compute accounts for 80−90% of query cost, and each call costs 105−107× a relational predicate. The latency window inverts a design constraint of classical adaptive query processing, where online learners had to stay lightweight to avoid dominating the predicates they optimize. At LLM latency, per-call gradient steps and per-batch threshold solves fit inside the round-trip. We develop compositional online learning at the LLM call boundary: a framework for combining online-learning components in semantic data processing systems. Each component makes execution-time decisions and refines its learned artifacts online. The design space spans two axes, decision granularity and learner update cadence, and the components share a single learning pattern that hides each trainer step inside the next LLM round-trip. A production case study in Cortex AISQL composes three components: a memoization layer, an online per-call filter-ordering learner, and an online per-batch cascade-routing learner. A conditional cost decomposition assigns each learning component to a distinct factor of per-row LLM cost. Under independence, the two learning components compose multiplicatively to an 11.4× upper bound on a representative conjunction-filter workload. Self-selection at the cascade boundary, sample-budget shrinkage, and selectivity-estimation drift reduce it to a realistic figure near 8×.
Figures & tables
Figure 1: The pipelined online-learning pattern. Phase 1 predicts the next decision and dispatches a background trainer step. Phase 2 issues the LLM call, which hides the trainer’s compute. Phase 3 records the outcome into the optimizer’s state. § 4 instantiates this at per-call cadence (one gradient step per LLM call). § 5 instantiates it at per-batch cadence (calibration fit and threshold solve on a doubling schedule).
Layer
Decision granularity
Learner update cadence
Artifact / state
Instance
Response caching
per-call
none (memoization)
exact-match response cache
AISQL response cache (§ 2.3 )
Filter ordering
per-call
online per-call
selectivity model + DP solver
Larch (§ 4 )
Cascade routing
per-row
online per-batch
calibrated GAM probability map
GAMCAL (§ 5 )
Prompt caching
per-call
none (memoization)
prefix cache + affinity map
future direction (§ 8.1 )
Model substitution
per-batch
one-shot at compile time
distilled student net
future direction (§ 8.1 )
Prompt structure
per-call
online per-batch
prompt template / rewriting rules
future direction (§ 8.1 )
Table 1: The layered design space. Three rows are populated by the AISQL instantiation: response caching (§ 2.3 ), filter ordering (§ 4 ), and cascade routing (§ 5 ). The remaining four rows name LLM-bound research directions revisited in § 8.1 . AQP-style layers populate analogous decisions at relational latency and are discussed in § 7 rather than in this LLM-bound design space.
Dataset
PZ
Quest
Larch-Sel
GovReport
21.3%
33.6%
5.1%
PubMed
26.1%
29.5%
6.5%
BigPatent
28.3%
29.7%
3.6%
Table 2: Token-overhead percentages relative to the per-row optimal lower bound on the Mix workload (50% AND, 50% OR) across three datasets [ 20 ] . Lower is better.
Dataset
SUPG-SP (LOTUS)
SUPG-IT
GAMCAL
ArXiv
55.6%
61.9%
61.6%
BoolQ
69.7%
58.2%
29.3%
IMDB
69.9%
69.1%
68.4%
MMLU
67.4%
62.9%
43.9%
NYT
21.9%
22.4%
17.0%
SST-2
28.6%
31.6%
21.2%
Table 3: Minimum delegation rate d required to reach F1≥0.95 across all six benchmarks [ 21 ] . Lower is better. Bold marks the best algorithm per row. GAMCAL leads on five of six datasets, often by a wide margin.
Configuration
eˉ
pdeleg
Cost (rel.)
Baseline (no optimization)
5.0
1.0
1.00
+ Filter ordering alone
≈1.25
1.0
≈0.25
+ Cascade routing alone
5.0
≈0.30
≈0.35
Both learning components (upper bound)
≈1.25
≈0.30
≈0.0875 ( 11.4× )
Table 4: Cost relative to the no-optimization baseline at m=5 and cproxy/coracle=0.05 . The two-component upper bound is 11.4× under § 6.2 ’s independence assumption and matched-precondition calibration ( D1=D1⋆ in the sense of § 6.1 ). § 6.4 catalogs cross-component interactions that lower the realistic figure to roughly 8× .
Large language model routing selects models, tools, experts, or inference strategies to balance answer quality, cost, latency, and deployment constraints.