summaryrefslogtreecommitdiffstats
path: root/health/guides/mysql/mysql_10s_slow_queries.md
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-03-09 13:19:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-03-09 13:20:02 +0000
commit58daab21cd043e1dc37024a7f99b396788372918 (patch)
tree96771e43bb69f7c1c2b0b4f7374cb74d7866d0cb /health/guides/mysql/mysql_10s_slow_queries.md
parentReleasing debian version 1.43.2-1. (diff)
downloadnetdata-58daab21cd043e1dc37024a7f99b396788372918.tar.xz
netdata-58daab21cd043e1dc37024a7f99b396788372918.zip
Merging upstream version 1.44.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'health/guides/mysql/mysql_10s_slow_queries.md')
-rw-r--r--health/guides/mysql/mysql_10s_slow_queries.md25
1 files changed, 25 insertions, 0 deletions
diff --git a/health/guides/mysql/mysql_10s_slow_queries.md b/health/guides/mysql/mysql_10s_slow_queries.md
new file mode 100644
index 000000000..173218448
--- /dev/null
+++ b/health/guides/mysql/mysql_10s_slow_queries.md
@@ -0,0 +1,25 @@
+### Understand the alert
+
+This alert presents the number of slow queries in the last 10 seconds. If you receive this, it indicates a high number of slow queries.
+
+The metric is raised in a warning state when the value is larger than 10. If the number of slow queries in the last 10 seconds exceeds 20, then the alert is raised in critical state.
+
+Queries are defined as "slow", if they have taken more than `long_query_time` seconds, a predefined variable. Also, the value is measured in real time, not CPU time.
+
+### Troubleshoot the alert
+
+- Determine which queries are the problem and try to optimise them
+
+To identify the slow queries, you can enable the slow-query log of MySQL:
+
+1. Locate the `my.cnf` file
+2. Enable the slow-query log by setting the `slow_query_log variable` to `On`.
+3. Enter a path where the log files should be stored in the `slow_query_log_file` variable.
+
+After you know which queries are the ones taking longer than preferred, you can use the `EXPLAIN` keyword to overview how many rows are accessed, what operations are being done etc.
+
+After you've found the cause for the slow queries, you can start optimizing your queries. Consider to use an index and think about how you can change the way you `JOIN` tables. Both of these methods aid to reduce the amount of data that is being accessed without it really being needed.
+
+### Useful resources
+[SQL Query Optimisation](https://opensource.com/article/17/5/speed-your-mysql-queries-300-times)
+