Skip to content

Commit 4b52a3d

Browse files
author
Wiktor Maj
authored
Enable MySQL slow query log for performance diagnostics (#123)
1 parent 2f08bf3 commit 4b52a3d

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
* Dependabot updates for `github-actions` and `terraform` ecosystems. (#29)
1616
* CI workflow to build and push service images to GitHub Container Registry on master merge. (#97)
1717
* Pull-first with local build fallback for container images during deployment. (#97)
18+
* MySQL slow query log for queries exceeding 10 seconds or not using indexes. (#76)
1819
* Strengthen MySQL superset password: secrets module, expanded charset, 24 chars. (#89)
1920
* SQL Lab query row limits, timeout caps, and validation timeout. (#81)
2021
* Superset metastore and explore form data caching via Redis. (#79)

docs/PERFORMANCE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ The MySQL server is configured for cluster workloads with the following performa
3939
| `binlog_transaction_dependency_tracking` | `WRITESET` | Enables parallel replication on secondaries |
4040
| `max_connections` | `50` | Limits concurrent connections per MySQL node |
4141
| `max_connect_errors` | `50` | Blocks hosts after 50 failed connection attempts |
42+
| `slow_query_log` | `ON` | Logs queries exceeding `long_query_time` or not using indexes |
43+
| `long_query_time` | `10` | Threshold in seconds for slow query classification |
4244

4345
## Nginx Tuning
4446

@@ -67,3 +69,5 @@ The following tools and endpoints are available for cluster monitoring and diagn
6769
- **Celery monitoring**: `celery inspect ping` and `celery inspect stats` provide worker status. See
6870
[Celery Async Queries](https://superset.apache.org/docs/configuration/async-queries-celery/).
6971
- **Keepalived logs**: available at `/opt/default/mysql_router/log/keepalived.log` on management nodes.
72+
- **MySQL slow query log**: available at `/var/log/mysql/slow-queries.log` on each MySQL node. Captures queries
73+
exceeding 10 seconds and queries not using indexes.

services/mysql-server/mysql_config.cnf.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ ssl-key = "/etc/mysql/ssl/mysql_server_key.pem"
1414
require_secure_transport = "ON"
1515
max_connections = "50"
1616
max_connect_errors = "50"
17+
slow_query_log = "ON"
18+
long_query_time = "10"
19+
log_queries_not_using_indexes = "ON"
20+
slow_query_log_file = "/var/log/mysql/slow-queries.log"
1721
replica_parallel_workers = "4"
1822
replica_parallel_type = "LOGICAL_CLOCK"
1923
replica_preserve_commit_order = "ON"

0 commit comments

Comments
 (0)