Slow Query
On the Slow Query screen, you can monitor and view slow SQL that exceeds the threshold time set in DB parameters. MySQL records slow queries to a log file or table, but to check them, you need to connect to the DB server via terminal and read the text log directly or query the mysql.slow_log table. This screen collects slow query logs in real time and provides them as visual charts and lists.
-
In the Slow Query chart, you can visually identify when slow queries occurred and their execution time.
-
In Slow Query List, you can check detailed information for individual queries and view execution plans (Plan).
-
Both real-time (Live) mode and historical time queries are supported.
An additional agent is required to collect slow queries. In on-premises environments, install the XOS agent, and in cloud (AWS RDS, etc.) environments, install the DBXC agent.
The slow query chart is similar to the SQL Elapse Map chart on the dashboard, but with the following differences:
| Category | Slow Query | SQL Elapse Map |
|---|---|---|
| Data Source | Slow query log recorded by DB | Active sessions collected by the agent at 5-second intervals |
| Execution Time Accuracy | Accurate — actual execution time recorded by DB | Up to 5 seconds of error possible due to 5-second interval collection |
| Collection Target | Only queries exceeding the threshold time (long_query_time) | All active sessions running at the time of collection |
Prerequisites
To display data on this screen, DB configuration, DBX Agent configuration, and either XOS Agent or DBXC Agent configuration depending on your environment are required.
DB configuration
Set the slow query-related parameters in my.cnf (or my.ini). MySQL restart is required after changes.
slow_query_log = 1
long_query_time = 3
log_output = FILE
| Parameter | Description |
|---|---|
slow_query_log | Whether to enable slow query logging. Enabled when set to 1. |
long_query_time | Records SQL that exceeds the set value (seconds) in the log. For example, if set to 3, SQL taking 3 or more seconds is recorded. |
log_output | Log storage method. FILE records to a file; TABLE records to the mysql.slow_log table. |
If log_output=TABLE is set, you must grant query permission to the monitoring account. Note that TABLE mode may impact DB performance if there are many slow queries.
GRANT SELECT ON mysql.slow_log TO whatap;
DBX Agent configuration
In whatap.conf, the slow_query_log option defaults to ON, so no additional configuration is needed.
slow_query_log=ON
| Option | Type | Default | Description |
|---|---|---|---|
slow_query_log | Boolean | ON | Enable slow query log collection |
OS agent configuration
An agent matching the DB operating environment is required to collect slow query logs.
| Environment | Required Agent | Key Configuration | Setup Guide |
|---|---|---|---|
| On-premises (Linux, Windows) | XOS agent | None (if auto-detection fails, specify log file path directly in slow_query=) | XOS Agent Configuration |
| Cloud (AWS RDS, NCP, etc.) | DBXC agent | slow_query: true (per-instance setting in config.yaml) | DBXC Agent Configuration |
Slow Query
Basic options
In the top filter area of the slow query screen, you can select the time period and target DB instance to query.
-
Time: Select real-time (Live) mode or a past time. Live mode automatically refreshes every 10 seconds.
-
Instance: Select the target DB instance to query. You can select all or individual instances.
Slow Query chart
Displays the time when slow queries occurred as a scatter chart. The Y-axis is execution time (seconds) and the X-axis is time.
-
Each dot represents one slow query; dots higher up indicate queries that took longer.
-
Mouse drag on the chart area displays only the queries from that interval in the list below.
-
The ∧ / ∨ buttons in the upper right adjust the Y-axis range.
Slow Query List
Displays the list of slow queries in the selected interval from the chart.
| Column | Description |
|---|---|
Instance | Name of the instance where the query was executed |
DB | Database name |
Start Time | Query start time |
User | Executing user name |
Host | Connection host |
ID | Thread ID |
Schema | Schema name |
QC Hit | Whether the query cache was hit |
Query Time (s) | Query execution time (seconds) |
Lock Time (s) | Lock wait time (seconds) |
Rows Sent | Number of rows returned to the client |
Rows Examined | Number of rows examined for query processing |
Rows Affected | Number of rows changed |
Bytes Sent | Number of bytes sent to the client |
SQL | Executed SQL statement |
SQL details
Click the query in the SQL column to open the details window.
Data interpretation guide
Key checkpoints
-
Queries with long Query Time: Queries with long individual execution time → SQL tuning, index check
-
Queries with long Lock Time: Long lock wait causing performance degradation → Check for transaction contention and lock causes
-
Queries with large Rows Examined: When the number of rows examined is large relative to rows returned → Missing index or inefficient scan
-
When the same SQL appears repeatedly: A specific query is consistently slow → Fundamental tuning required
-
Concentrated in a specific time period: Check for external factors such as DB load, lock contention, batch jobs during that time
Practical usage scenarios
Scenario 1: Real-time monitoring of slow queries
-
Observe the Slow Query chart in Live mode
-
When new dots appear, drag and select that area
-
Check queries in the Slow Query List → Click SQL to view details and execution plan
Scenario 2: Analyzing slow queries in a specific time period
-
Select the problematic time period in the time filter
-
Drag the interval where queries are concentrated in the chart
-
Check queries with the longest Query Time first to analyze the cause
Scenario 3: Adjusting the slow query threshold
-
If too many slow queries are being collected, raise the
long_query_timevalue to loosen the threshold -
If no slow queries are being collected, lower the
long_query_timevalue or check theslow_query_log=ONsetting
Analyzing with AI
Click the WhaTap AI button on the screen to open the WhaTap AI chat window, where the queried screen data is summarized and the analysis result is shown as a conversation. After reading the result, you can continue with follow-up questions in the same conversation.
-
The data used for the analysis is the top 20 items with the longest elapsed time among the items selected on the scatter plot.
-
The analysis target is the data queried on the screen. If you change the query conditions and analyze again, the analysis is based on the changed data.
-
The conversation history is recorded in the
AI Analysis - {screen name}format.