Skip to main content
VeloDB Cloud 26.x is based on Apache Doris 4.x. See Version Mapping.

Workload Analysis and Diagnosis

Use cluster metrics, workload group metrics, and query history together to identify the source of resource pressure. Running-query tables help you respond to an incident. Audit records help you compare current behavior with an earlier period and tune recurring workloads.

Connect to the cluster you are investigating. The SQL examples use system tables in information_schema. Access and result visibility depend on the SQL user's privileges. See the linked system table references.

Analyze running work​

  1. Check cluster CPU, memory, and I/O metrics for the affected time range. Identify the resource under pressure before changing limits.
  2. Query information_schema.workload_group_resource_usage to identify groups consuming that resource. Compare the groups across backend (BE_ID) rows rather than treating one backend's value as a cluster total.
  3. Reduce new work from the affected group if the cluster is saturated. Review its queue limits and the application's submission concurrency.
  4. If necessary, adjust the group's current resource properties with ALTER WORKLOAD GROUP ... FOR <cluster>. Use max_cpu_percent for CPU, max_memory_percent for memory, and the scan throughput properties for I/O. See Workload Groups for their scope and constraints. Lowering memory limits can cause active queries to fail.
  5. Use information_schema.backend_active_tasks and information_schema.active_queries to distinguish a concurrency increase from a small number of expensive queries. Cancel a query only after identifying its owner and effect.
  6. Compare metrics and application failures after each change. If the remaining workload needs more compute capacity, review cluster scaling.

Note:

active_queries reports work registered with frontends (FEs). backend_active_tasks reports running backend work, including load tasks that might have no corresponding frontend query row. A LEFT JOIN with no matching active_queries row is therefore expected for some tasks. It does not prove that the task is orphaned. A backend load task ID alone is not a promise that KILL QUERY can cancel that load. Use the load method's cancellation command when appropriate.

Analyze historical work​

  1. Use cluster monitoring to identify the affected time range and resource.
  2. Inspect available audit records for the same interval. The audit log table records query duration, scanned rows and bytes, CPU time, and other execution metrics when audit collection is available.
  3. Compare against a representative healthy interval. Business expectations and percentile distributions can help identify outliers. For example, a substantial increase in median CPU time relative to the earlier upper percentiles suggests that many more queries are expensive. Thresholds must reflect your workload, rather than a universal row-count or duration limit.
  4. Tune outlier queries through SQL rewrites, table design, query plans, or execution settings. Use Query Profile to inspect where execution time and resources are spent.
  5. If individual query resource use is normal, compare query volume and concurrency. Review upstream traffic changes, admission controls, and cluster capacity.

Audit tables can contain SQL text and connection information. Grant access only to SQL users who need it. Historical coverage depends on collection and retention settings, so an absent record is not proof that a query did not run.

Diagnostic SQL​

Each example is a snapshot of running work. Counters can change while you query them. CPU time is cumulative work across tasks and can exceed wall-clock duration.

Example 1: Rank workload groups by memory use​

Compare per-backend workload group resource use
SELECT be_id,
workload_group_id,
memory_usage_bytes,
cpu_usage_percent,
local_scan_bytes_per_second,
remote_scan_bytes_per_second
FROM information_schema.workload_group_resource_usage
ORDER BY memory_usage_bytes DESC, cpu_usage_percent DESC,
local_scan_bytes_per_second DESC;

The rows remain separate for each backend. Use the CPU and I/O columns to choose a different sort order when investigating a different bottleneck.

Example 2: Rank queries by CPU time​

Join backend CPU counters with query text
SELECT t1.query_id AS be_query_id,
t1.query_type,
t2.query_id,
t2.workload_group_id,
t2.`database`,
t1.cpu_time_ms,
t2.`sql`
FROM (
SELECT query_id, query_type, SUM(task_cpu_time_ms) AS cpu_time_ms
FROM information_schema.backend_active_tasks
GROUP BY query_id, query_type
) t1
LEFT JOIN information_schema.active_queries t2 ON t1.query_id = t2.query_id
ORDER BY cpu_time_ms DESC
LIMIT 10;

Example 3: Rank queries by current memory use​

Sum currently used memory across backend task rows
SELECT t1.query_id AS be_query_id,
t1.query_type,
t2.query_id,
t2.workload_group_id,
t1.mem_used
FROM (
SELECT query_id, query_type,
SUM(current_used_memory_bytes) AS mem_used
FROM information_schema.backend_active_tasks
GROUP BY query_id, query_type
) t1
LEFT JOIN information_schema.active_queries t2 ON t1.query_id = t2.query_id
ORDER BY mem_used DESC
LIMIT 10;

Example 4: Rank queries by scan volume​

Find running queries with the most scanned rows and bytes
SELECT t1.query_id AS be_query_id,
t1.query_type,
t2.query_id,
t2.workload_group_id,
t1.scan_rows,
t1.scan_bytes
FROM (
SELECT query_id, query_type,
SUM(scan_rows) AS scan_rows, SUM(scan_bytes) AS scan_bytes
FROM information_schema.backend_active_tasks
GROUP BY query_id, query_type
) t1
LEFT JOIN information_schema.active_queries t2 ON t1.query_id = t2.query_id
ORDER BY scan_rows DESC, scan_bytes DESC
LIMIT 10;

Example 5: Summarize scan volume by workload group​

Aggregate backend work by its recorded workload group ID
SELECT workload_group_id,
SUM(scan_rows) AS wg_scan_rows,
SUM(scan_bytes) AS wg_scan_bytes
FROM information_schema.backend_active_tasks
GROUP BY workload_group_id
ORDER BY wg_scan_rows DESC, wg_scan_bytes DESC;

The workload group ID is available directly on backend task rows. This preserves groups for load tasks that have no frontend query row.

Example 6: Inspect queued queries​

Find queued work and its recorded queue start time
SELECT workload_group_id,
query_id,
query_status,
queue_start_time
FROM information_schema.active_queries
WHERE query_status = 'queued'
ORDER BY workload_group_id, queue_start_time;

queue_start_time is a formatted string. Inspect it alongside the recorded timestamps and time-zone behavior rather than subtracting it directly from NOW() as a numeric value.

See also​