Arturo Iacobelli
03/12/2026, 5:47 PMRocky
03/12/2026, 5:47 PMenable_query_queue_select) and enable_query_queue_v2 (an FE configuration) lies in the underlying scheduling architecture and the sophistication of how queries are prioritized.
*1. Core Purpose*
* Query Queue (V1/Legacy): This refers to the original queuing mechanism introduced in v2.5. It monitors resource thresholds (CPU, memory, and concurrency) on BE nodes. When these thresholds are exceeded, new queries are placed in a queue. It primarily uses a basic "First-In-First-Out" (FIFO) approach for global queues.
* Query Queue V2 (enable_query_queue_v2): This is an FE-level configuration (in fe.conf) that upgrades the internal slot-based scheduler. It was introduced to provide more intelligent and fair scheduling of queries waiting in that queue.
*2. Key Technical Differences*
Feature | Legacy Query Queue (V1) | Query Queue V2
Config Type | Session Variables (enable_query_queue_select, etc.) | FE Configuration (fe.conf)
Scheduling Strategy | Simple FIFO (mostly) | Advanced: SWRR or SJF
Resource Management | Threshold-based (BE reports usage) | Slot-based (Centralized FE management)
Fairness | Limited | High (Weighted Round Robin)
Default | Disabled by default | true (from v4.1 onwards)
*3. What V2 Adds*
When you enable enable_query_queue_v2 = true in your FE configuration, you gain access to advanced scheduling policies controlled by the query_queue_v2_schedule_strategy parameter:
* SWRR (Smooth Weighted Round Robin): The default in V2. It ensures that different resource groups or workloads get a fair share of the available slots based on their weights, preventing large queries from completely starving smaller ones.
* SJF (Short Job First + Aging): Prioritizes shorter, faster queries to reduce overall latency, while using an "aging" mechanism to ensure long-running queries aren't stuck in the queue forever.
*4. How they work together*
They are not mutually exclusive; rather, V2 improves how the queue behaves once it is active.
1. Activation: You still use session variables like SET GLOBAL enable_query_queue_select = true; to tell StarRocks to queue queries when the system is busy.
2. Execution Logic: If enable_query_queue_v2 is true in your fe.conf, StarRocks uses the new slot-manager and SWRR/SJF strategies to decide which query from the queue gets to run next as resources become available.
Summary
* Use the legacy variables (enable_query_queue_select/load) to turn the queuing feature on or off for specific query types.
* Use enable_query_queue_v2 (v3.3.4+) to enable the more modern, slot-based scheduling engine that handles mixed workloads more efficiently than the original implementation.
References
• administration/management/FE_configuration.md
• administration/management/resource_management/query_queues.md
• sql-reference/System_variable.mdRocky
03/12/2026, 5:48 PMenable_query_queue_v2) lies in how queries are scheduled and how resources are managed.
Here is a breakdown of the differences:
*1. Underlying Mechanism*
* Legacy (V1): Relies on resource usage reported by Backend (BE) nodes (CPU, memory, and concurrency). Because BEs report these statistics to the Frontend (FE) at intervals (default 1s), there can be a delay. This means the system might occasionally over-admit queries before the FE realizes the threshold has been reached.
* Query Queue V2 (enable_query_queue_v2): Uses a slot-based scheduler managed by the FE. It calculates the total available "slots" in the cluster based on BE resources and manages query admission more strictly and collectively at the FE level, reducing the "reporting delay" issue.
*2. Scheduling Strategies*
* Legacy (V1): Primarily follows a simpler scheduling logic (mostly FIFO) based on available thresholds.
* Query Queue V2: Introduces advanced scheduling policies via the query_queue_v2_schedule_strategy parameter:
* SWRR (Smooth Weighted Round Robin): The default strategy. It provides fair weighted sharing, which is ideal for mixed workloads (e.g., long-running ETL vs. short analytics).
* SJF (Short Job First + Aging): Prioritizes shorter jobs to reduce latency for small queries while using an "aging" mechanism to ensure long queries don't starve.
*3. Concurrency Calculation*
* Legacy (V1): Managed via the session variable query_queue_concurrency_limit which limits queries per BE.
* Query Queue V2: Uses query_queue_v2_concurrency_level to determine total cluster capacity.
_ Total Slots = concurrency_level _ number_of_BEs * cores_per_BE.
* This provides a more global view of cluster capacity rather than just per-node limits.
*4. Configuration Type*
* enable_query_queue_v2 is an FE configuration (found in fe.conf). It determines which "engine" handles the queuing logic.
* To actually activate queuing for your queries, you still use session variables regardless of the version:
* SET GLOBAL enable_query_queue_select = true;
* SET GLOBAL enable_query_queue_load = true;
*5. Default Status*
* Query Queue V2 was introduced in versions v3.3.4, v3.4.0, and v3.5.0.
* Starting from v4.1 onwards, enable_query_queue_v2 is set to true by default.
Summary Table
Feature | Legacy Query Queue (V1) | Query Queue V2
FE Configuration | N/A (Original mechanism) | enable_query_queue_v2 = true
Scheduler | BE-report based | FE Slot-based
Fairness | Basic | Advanced (SWRR, SJF)
Accuracy | Subject to reporting delays | Higher accuracy (FE managed)
Best For | Simple concurrency control | Complex, multi-tenant, or hybrid workloads
Recommendation: If you are on v3.3+ or v3.4+, it is recommended to use Query Queue V2 for better stability and fairer resource distribution among different users and resource groups.
References
• administration/management/FE_configuration.md
• administration/management/resource_management/query_queues.mdPhilip Oliva
03/12/2026, 7:04 PMRocky
03/12/2026, 7:04 PMPhilip Oliva
03/12/2026, 7:05 PMenable_query_queue_v2 that explains how it works more clearly?Rocky
03/12/2026, 7:05 PMenable_query_queue_v2 (introduced in v3.3.4 and enabled by default from v4.1 onwards) switches StarRocks from a simple concurrency-based threshold to a more sophisticated Slot-based Query Scheduler.
Here is a breakdown of how it works:
1. The Concept of "Slots"
Instead of just counting the number of queries, V2 views the cluster's capacity as a pool of Logical Slots.
* Total Slots calculation: The total capacity is calculated based on your cluster size:
Total Slots = query_queue_v2_concurrency_level _ number_of_BEs _ CPU_cores_per_BE
* By default, query_queue_v2_concurrency_level is 4. This means if you have 2 BEs with 16 cores each, your cluster has $4 \times 2 \times 16 = 128$ slots.
2. Slot Estimation (How much "weight" is a query?)
When a query arrives, the FE estimates how many slots it requires before allowing it to run. This is governed by the `query_queue_slots_estimator_strategy`:
* MBE (Memory-Based Estimation): Calculates slots based on predicted memory or plan costs.
* PBE (Parallelism-Based Estimation): Calculates slots based on fragment parallelism (how many scan ranges it hits) and CPU costs.
* MAX (Default): Takes the higher of the two. A heavy query with high parallelism or high memory will consume more slots, naturally limiting how many such queries can run at once.
3. Scheduling Strategies
When the slots are full and queries begin to queue, you can choose how they are prioritized via `query_queue_v2_schedule_strategy`:
* SWRR (Smooth Weighted Round Robin): The default. It ensures fair resource distribution among different users/resource groups.
* SJF (Short Job First + Aging): Prioritizes smaller, faster queries to improve interactive performance, while using an "aging" mechanism to ensure large queries aren't stuck forever.
4. Key Configuration Parameters
If you want to tune this behavior, keep an eye on these FE configurations:
* `query_queue_v2_concurrency_level`: Increase this if you have high-concurrency small queries and want to pack more in; decrease it if you are hitting memory issues.
* `query_queue_v2_cpu_costs_per_slot`: Controls how many "CPU cost units" equal one slot.
* `query_queue_v2_num_rows_per_slot`: Controls how many source rows correspond to one slot (default is 4096).
Why use V2?
The legacy query queue (v1) relied on BEs reporting their status back to the FE, which often had a delay. V2 is managed directly by the Leader FE, making the scheduling much more "real-time" and preventing resource exhaustion before it happens by accurately weighing queries during the planning phase.
Do you have a specific version you're running, or are you seeing queries queue unexpectedly? I can help you tune these parameters!
References
• administration/management/FE_configuration.md
• administration/management/resource_management/query_queues.mdPhilip Oliva
03/12/2026, 7:07 PMenable_query_queue_v2 if I want to prioritize stopping cpu saturation on BEs?Rocky
03/12/2026, 7:08 PMSELECT) and ensure the V2 scheduler is active.
sql
-- Enable queuing for SELECT queries
SET GLOBAL enable_query_queue_select = true;
-- Ensure V2 scheduler is enabled (default in v4.1+)
-- This replaces the legacy V1 logic with the slot-based V2 logic.
ADMIN SET FRONTEND CONFIG ("enable_query_queue_v2" = "true");
2. Configure CPU-Based Slot Calculation
To prioritize CPU saturation, you need to tune how many "slots" a query consumes based on its estimated CPU cost. The scheduler calculates slots as max(CPU_slots, Memory_slots). To make CPU the bottleneck:
* query_queue_v2_concurrency_level: This determines the total number of slots available in the cluster.
* Calculation: Total Slots = concurrency_level * total_BE_cores.
* Recommendation: Keep this at the default (4) or lower if you want to be more conservative. A lower value reduces the total "capacity" for concurrent work.
* query_queue_v2_cpu_costs_per_slot: This is the most critical setting for CPU prioritization.
* Logic: CPU Slots = Query Planner CPU Cost / query_queue_v2_cpu_costs_per_slot.
* Action: Decrease this value to make queries "heavier" in terms of CPU slots. This forces high-CPU queries to take up more slots, causing subsequent queries to queue earlier and preventing the BEs from being overwhelmed by too many intensive tasks.
sql
-- Example: Make queries consume more slots per unit of CPU cost
-- Default is 1,000,000,000. Lowering it increases CPU-based queuing.
ADMIN SET FRONTEND CONFIG ("query_queue_v2_cpu_costs_per_slot" = "500000000");
3. Summary of Minimum Settings (FE Config)
To effectively stop CPU saturation, adjust these parameters in your fe.conf or via `ADMIN SET FRONTEND CONFIG`:
Parameter | Purpose for CPU Protection
enable_query_queue_v2 | Switches to the advanced slot-based scheduler.
query_queue_v2_concurrency_level | Limits total system concurrency relative to available cores.
query_queue_v2_cpu_costs_per_slot | Controls how much estimated CPU cost equals one "concurrency slot."
Proactive Tip: Resource Groups
While enable_query_queue_v2 manages global concurrency, for the strongest CPU protection, use Resource Groups with a max_cpu_cores limit. This allows the system to hard-limit the CPU cores a specific group of queries can use, preventing them from ever saturating the entire BE node regardless of the queue.
sql
CREATE RESOURCE GROUP heavy_queries
PROPERTIES (
"cpu_core_limit" = "16", -- Hard limit on cores used
"concurrency_limit" = "10"
);
References
• administration/management/FE_configuration.md
• administration/management/resource_management/query_queues.md
• sql-reference/System_variable.md