Paper ReviewComputer SystemsExperimental Design

Paged Memory Meets Query Execution: Adaptive Resource Management for Analytics Under Pressure

Database query executors assume fixed memory allocationsโ€”but real workloads compete for memory dynamically. Otaki et al. propose resource-adaptive query execution that adjusts algorithms on the fly when memory pressure changes, preventing the catastrophic performance cliffs that occur when analytics queries spill to disk.

By Sean K.S. Shin
This blog summarizes research trends based on published paper abstracts. Specific numbers or findings may contain inaccuracies. For scholarly rigor, always consult the original papers cited in each post.

Every database textbook teaches that hash joins are faster than sort-merge joins for large tables, and that in-memory aggregation outperforms disk-based spilling. These performance relationships hold when the query executor has sufficient memory. They catastrophically invert when memory is scarceโ€”a hash join that overflows to disk can be orders of magnitude slower than a sort-merge join that fits in memory.

In production database systems, memory is shared among concurrent queries, background processes, and the operating system. The amount of memory available to any single query fluctuates continuously as other workloads start and stop. A query plan chosen at optimization time based on assumed memory availability may become suboptimalโ€”or catastrophically slowโ€”by the time it executes, because memory conditions have changed.

Otaki et al. address this with resource-adaptive query execution: a runtime system that monitors available memory and dynamically adjusts query algorithms as memory pressure changes. Rather than choosing a single execution plan at compilation time and hoping memory conditions hold, the adaptive executor maintains the ability to switch strategies mid-executionโ€”transitioning from hash-based to sort-based algorithms when memory shrinks, or upgrading to hash-based algorithms when memory becomes available.

The Performance Cliff Problem

The performance cliff occurs at the transition from in-memory to disk-spilling execution. A hash join operating entirely in memory might process a million rows per second. The same hash join, when its hash table exceeds available memory and spills partitions to disk, might process only thousands of rows per secondโ€”a performance degradation of 100x or more.

Traditional database systems attempt to prevent spilling through careful memory allocation: the optimizer estimates memory requirements, the memory manager reserves appropriate amounts, and queries proceed with their allocated budgets. This works when memory estimation is accurate and workloads are predictable. It fails when:

  • Multiple large queries arrive simultaneously, each expecting full memory availability
  • Memory estimation is inaccurate (common for queries with complex predicates or skewed data)
  • Background processes (compaction, index maintenance, statistics gathering) consume memory unpredictably
The resource-adaptive approach accepts that memory availability is inherently unpredictable and builds adaptation into the execution engine itself.

Paged Memory Management for Queries

The paging mechanism adapts the operating system's virtual memory concept to query execution. Query execution operators (joins, aggregations, sorts) are implemented with paged memory interfaces that:

  • Allocate incrementally: Rather than requesting a large contiguous memory block upfront, operators allocate memory in small pages as needed
  • Release gracefully: When memory pressure is detected, operators can release pages without abortingโ€”they continue execution with reduced memory by switching to more memory-efficient (but slower) algorithms
  • Adapt continuously: The executor monitors system-wide memory pressure and sends signals to operators, allowing them to adjust their memory consumption in real time
  • Dynamic Programming for Plan Selection

    Kozlova & Filippov provide a complementary perspective from PostgreSQL's query optimizer, which uses dynamic programming to select query plans from an exponentially large space of possibilities. Their analysis of how PostgreSQL's optimizer navigates the join ordering problemโ€”considering memory, I/O, and CPU costs simultaneouslyโ€”reveals both the sophistication of modern query planners and their limitations when runtime conditions diverge from planning-time assumptions.

    The connection to resource-adaptive execution is direct: even the best plan selected by dynamic programming at optimization time becomes suboptimal when runtime memory conditions differ from the optimizer's assumptions. Adaptive execution addresses this gap by maintaining multiple viable strategies and switching between them as conditions change.

    Claims and Evidence

    <
    ClaimEvidenceVerdict
    Memory scarcity causes catastrophic query performance degradationWell-documented in database systems literature and production experienceโœ… Well-established
    Resource-adaptive execution prevents performance cliffsOtaki et al. demonstrate graceful degradation under memory pressureโœ… Supported
    Paged memory management reduces peak memory requirementsIncremental allocation avoids large upfront reservationsโœ… Supported
    Adaptation overhead is negligible compared to spill penaltyMonitoring and switching cost is small relative to disk I/O costโœ… Supported
    Current production databases implement full resource adaptationMost databases use static memory allocation with limited adaptationโŒ Not yet mainstream

    Open Questions

  • Adaptation granularity: Should operators adapt individually or should the executor coordinate adaptation across all concurrent operators? Individual adaptation is simpler but may lead to oscillation; coordinated adaptation is more stable but more complex.
  • Prediction vs. reaction: Should the system predict memory pressure before it occurs (using workload forecasting) or react after it is detected? Prediction enables proactive adaptation but requires accurate workload models.
  • User expectations: If a query plan adapts mid-execution, the query's resource consumption and latency become unpredictable. How do we set user expectations and provide progress estimates for adaptive queries?
  • Cloud cost implications: In cloud databases where users pay per resource-second, adaptive execution that uses more CPU to compensate for less memory affects billing. How should adaptive resource usage be priced?
  • What This Means for Your Research

    For database systems researchers, resource-adaptive execution is a promising direction that aligns query execution with the reality of shared, variable-resource environments. The gap between static planning and dynamic execution represents an opportunity for significant practical impact.

    For data engineers managing analytics workloads, the key insight is that memory configuration is not just a one-time tuning taskโ€”it is a dynamic resource that requires continuous management. Systems that adapt to memory pressure will increasingly outperform those that assume fixed allocations.

    References (2)

    [1] Otaki, R., Benello, C., Elmore, A. (2025). Resource-Adaptive Query Execution with Paged Memory Management. Semantic Scholar.
    [2] Kozlova, I. & Filippov, M. (2025). APPLICATION OF DYNAMIC PROGRAMMING FOR THE TASK OF SELECTING A QUERY PLAN IN POSTGRESQL RELATIONAL DATABASE MANAGEMENT SYSTEM. Herald of Computer and Information Technologies.

    Explore this topic deeper

    Search 290M+ papers, detect research gaps, and find what hasn't been studied yet.

    Click to remove unwanted keywords

    Search 8 keywords โ†’