Slow Query Diagnostic Tools
Use Query Audit to find completed queries that need tuning. Use Sessions when a query is still running. Both views help you identify the SQL statement, user, database, execution duration, and query ID before you investigate the execution plan or profile.
Prepare to diagnose slow queries
- Confirm the warehouse and cluster used by the application.
- Record the time range and the application's expected response time.
- Confirm that query auditing is enabled and that the required records are within its retention period. See Query Audit configuration.
- Distinguish database execution time from application delays such as connection setup, queueing, and result processing.
Do not rely on a universal slow-query threshold. Start with your application's latency target and compare the duration of representative queries under similar load.
Choose a diagnostic view
| View | Use it for | Next action |
|---|---|---|
| Query Audit | Completed queries and historical incidents | Filter the time range, inspect execution details, and open an available profile. |
| Sessions | Queries that are still executing | Inspect the query before deciding whether to wait or terminate it. |
| SQL Editor query history | Statements submitted from SQL Editor | Find the statement and open its profile when a query ID is available. |
| Metrics | Resource pressure during the incident | Compare warehouse and cluster metrics with query duration. |
Find completed queries
- Open Query Audit for the warehouse.
- Use Logs, Status, and Time to focus on the incident.
- Review Execution Duration, CPU Time, and Peak Memory Usage alongside the SQL statement. Prioritize queries that are slow, frequent, or expensive for the affected workload.
- Select a Query ID to inspect the query details. Record the SQL, user, database, cluster, start time, scanned rows, and returned rows.
- Select Query Profile when a profile is available. Use Analysis Tools to examine the plan and operator metrics.
You can export the filtered records from Query Audit for comparison or incident review. Narrow the time range before exporting a large history.
Inspect a running query
Open Sessions and filter by cluster, database, user, or host. Select a Query ID to inspect the SQL and execution details.
A long-running query may still be doing useful work. Confirm the statement and its business impact before using Terminate Session.
Record the evidence needed for analysis
| Evidence | Why it matters |
|---|---|
| Query ID and incident time range | Correlate the query with its profile and cluster metrics. |
| SQL and parameter values | Reproduce the same filters, joins, and result size. |
| Warehouse, cluster, database, and user | Identify the execution environment and workload. |
| Execution duration, CPU time, and peak memory | Compare latency with resource consumption. |
| Scanned and returned rows | Identify large scans or low-selectivity filters. |
| Execution plan and available query profile | Compare estimated work with actual execution. |
Prioritize repeated query patterns
Queries that differ only in literal values can share a tuning problem. Group exported statements by their application query template, then compare their frequency, cumulative duration, and resource use. Keep the original SQL and parameter values for representative executions because different values can produce different selectivity and data skew.
Tune a pattern when it repeatedly affects the workload, then verify the change with several representative parameter values. A faster execution for one value does not establish an improvement for the whole pattern.
Troubleshoot missing records
| Symptom | Check |
|---|---|
| A completed query is missing | Confirm the warehouse, time range, filters, auditing status, and retention period. |
| The query is still running | Look in Sessions. |
| SQL Editor history does not contain the query | Use Query Audit for queries submitted by other clients. |
| A query has no profile | Confirm profile collection settings, then reproduce the query with profiling enabled if appropriate. See Query Profile. |
Note:
VeloDB Cloud manages engine hosts and service logs. Use the console diagnostics described here for SaaS and BYOC warehouses. If the available evidence is insufficient, provide the query ID, warehouse, cluster, and incident time range to VeloDB Cloud support.
Next steps
Use EXPLAIN and Query Profile to identify the bottleneck, then follow the Tuning Process to evaluate a targeted change.