advisory_rules_generic.txt 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. # phpMyAdmin Advisory rules file
  2. #
  3. # Use only UNIX style newlines
  4. #
  5. # This file is being parsed by Advisor.php, which should handle syntax
  6. # errors correctly. However, PHP Warnings and the like are being consumed by
  7. # the phpMyAdmin error handler, so those won't show up E.g.: Justification line
  8. # is empty because you used an unescape percent sign, sprintf() returns an
  9. # empty string and no warning/error is shown
  10. #
  11. # Rule Syntax:
  12. # 'rule' identifier[the name of the rule] eexpr [an optional precondition]
  13. # expr [variable or value calculation used for the test]
  14. # expr [test, if evaluted to 'true' it fires the rule. Use 'value' to insert the calculated value (without quotes)]
  15. # string [the issue (what is the problem?)]
  16. # string [the recommendation (how do i fix it?)]
  17. # formatted-string '|' comma-seperated-expr [the justification (result of the calculated value / why did this rule fire?)]
  18. # comma-seperated-expr: expr(,expr)*
  19. # eexpr: [expr] - expr enclosed in []
  20. # expr: a php code literal with extras:
  21. # - variable names are replaced with their respective values
  22. # - fired('name of rule') is replaced with true/false when given rule has
  23. # been fired. Note however that this is a very simple rules engine.
  24. # Rules are only checked in sequential order as they are written down
  25. # here. If given rule has not been checked yet, fired() will always
  26. # evaluate to false
  27. # - 'value' is replaced with the calculated value. If it is a string, it
  28. # will be put within single quotes
  29. # - other than that you may use any php function, initialized variable or
  30. # constant
  31. #
  32. # identifier: A string enclosed in single quotes
  33. # string: A quoteless string, may contain HTML. Variable names enclosed in
  34. # curly braces are replaced with links to directly edit this variable.
  35. # e.g. {tmp_table_size}
  36. # formatted-string: You may use classic php sprintf() string formatting here,
  37. # the arguments must be appended after a trailing pipe (|) as
  38. # mentioned in above syntax percent signs (%) are
  39. # automatically escaped (%%) in the following cases: When
  40. # followed by a space, dot or comma and at the end of the
  41. # line)
  42. #
  43. # Comments start with #
  44. #
  45. # Queries
  46. rule 'Uptime below one day'
  47. Uptime
  48. value < 86400
  49. Uptime is less than 1 day, performance tuning may not be accurate.
  50. To have more accurate averages it is recommended to let the server run for longer than a day before running this analyzer
  51. The uptime is only %s | ADVISOR_timespanFormat(Uptime)
  52. rule 'Questions below 1,000'
  53. Questions
  54. value < 1000
  55. Fewer than 1,000 questions have been run against this server. The recommendations may not be accurate.
  56. Let the server run for a longer time until it has executed a greater amount of queries.
  57. Current amount of Questions: %s | Questions
  58. rule 'Percentage of slow queries' [Questions > 0]
  59. Slow_queries / Questions * 100
  60. value >= 5
  61. There is a lot of slow queries compared to the overall amount of Queries.
  62. You might want to increase {long_query_time} or optimize the queries listed in the slow query log
  63. The slow query rate should be below 5%, your value is %s%. | round(value,2)
  64. rule 'Slow query rate' [Questions > 0]
  65. (Slow_queries / Questions * 100) / Uptime
  66. value * 60 * 60 > 1
  67. There is a high percentage of slow queries compared to the server uptime.
  68. You might want to increase {long_query_time} or optimize the queries listed in the slow query log
  69. You have a slow query rate of %s per hour, you should have less than 1% per hour. | ADVISOR_bytime(value,2)
  70. rule 'Long query time'
  71. long_query_time
  72. value >= 10
  73. {long_query_time} is set to 10 seconds or more, thus only slow queries that take above 10 seconds are logged.
  74. It is suggested to set {long_query_time} to a lower value, depending on your environment. Usually a value of 1-5 seconds is suggested.
  75. long_query_time is currently set to %ds. | value
  76. rule 'Slow query logging' [PMA_MYSQL_INT_VERSION < 50600]
  77. log_slow_queries
  78. value == 'OFF'
  79. The slow query log is disabled.
  80. Enable slow query logging by setting {log_slow_queries} to 'ON'. This will help troubleshooting badly performing queries.
  81. log_slow_queries is set to 'OFF'
  82. rule 'Slow query logging' [PMA_MYSQL_INT_VERSION >= 50600]
  83. slow_query_log
  84. value == 'OFF'
  85. The slow query log is disabled.
  86. Enable slow query logging by setting {slow_query_log} to 'ON'. This will help troubleshooting badly performing queries.
  87. slow_query_log is set to 'OFF'
  88. #
  89. # versions
  90. rule 'Release Series'
  91. version
  92. substr(value,0,2) <= '5.' && substr(value,2,1) < 1
  93. The MySQL server version less than 5.1.
  94. You should upgrade, as MySQL 5.1 has improved performance, and MySQL 5.5 even more so.
  95. Current version: %s | value
  96. rule 'Minor Version' [! fired('Release Series')]
  97. version
  98. substr(value,0,2) <= '5.' && substr(value,2,1) <= 1 && substr(value,4,2) < 30
  99. Version less than 5.1.30 (the first GA release of 5.1).
  100. You should upgrade, as recent versions of MySQL 5.1 have improved performance and MySQL 5.5 even more so.
  101. Current version: %s | value
  102. rule 'Minor Version' [! fired('Release Series')]
  103. version
  104. substr(value,0,1) == 5 && substr(value,2,1) == 5 && substr(value,4,2) < 8
  105. Version less than 5.5.8 (the first GA release of 5.5).
  106. You should upgrade, to a stable version of MySQL 5.5.
  107. Current version: %s | value
  108. rule 'Distribution'
  109. version_comment
  110. preg_match('/source/i',value)
  111. Version is compiled from source, not a MySQL official binary.
  112. If you did not compile from source, you may be using a package modified by a distribution. The MySQL manual only is accurate for official MySQL binaries, not any package distributions (such as RedHat, Debian/Ubuntu etc).
  113. 'source' found in version_comment
  114. rule 'Distribution'
  115. version_comment
  116. preg_match('/percona/i',value)
  117. The MySQL manual only is accurate for official MySQL binaries.
  118. Percona documentation is at <a href="https://www.percona.com/software/documentation/">https://www.percona.com/software/documentation/</a>
  119. 'percona' found in version_comment
  120. rule 'MySQL Architecture'
  121. system_memory
  122. value > 3072*1024 && !preg_match('/64/',version_compile_machine) && !preg_match('/64/',version_compile_os)
  123. MySQL is not compiled as a 64-bit package.
  124. Your memory capacity is above 3 GiB (assuming the Server is on localhost), so MySQL might not be able to access all of your memory. You might want to consider installing the 64-bit version of MySQL.
  125. Available memory on this host: %s | ADVISOR_formatByteDown(value*1024, 2, 2)
  126. #
  127. # Query cache
  128. rule 'Query caching method' [!fired('Query cache disabled')]
  129. Questions / Uptime
  130. value > 100
  131. Suboptimal caching method.
  132. You are using the MySQL Query cache with a fairly high traffic database. It might be worth considering to use <a href="https://dev.mysql.com/doc/refman/5.5/en/ha-memcached.html">memcached</a> instead of the MySQL Query cache, especially if you have multiple slaves.
  133. The query cache is enabled and the server receives %d queries per second. This rule fires if there is more than 100 queries per second. | round(value,1)
  134. #
  135. # Sorts
  136. rule 'Percentage of sorts that cause temporary tables' [Sort_scan + Sort_range > 0]
  137. Sort_merge_passes / (Sort_scan + Sort_range) * 100
  138. value > 10
  139. Too many sorts are causing temporary tables.
  140. Consider increasing {sort_buffer_size} and/or {read_rnd_buffer_size}, depending on your system memory limits.
  141. %s% of all sorts cause temporary tables, this value should be lower than 10%. | round(value,1)
  142. rule 'Rate of sorts that cause temporary tables'
  143. Sort_merge_passes / Uptime
  144. value * 60 * 60 > 1
  145. Too many sorts are causing temporary tables.
  146. Consider increasing {sort_buffer_size} and/or {read_rnd_buffer_size}, depending on your system memory limits.
  147. Temporary tables average: %s, this value should be less than 1 per hour. | ADVISOR_bytime(value,2)
  148. rule 'Sort rows'
  149. Sort_rows / Uptime
  150. value * 60 >= 1
  151. There are lots of rows being sorted.
  152. While there is nothing wrong with a high amount of row sorting, you might want to make sure that the queries which require a lot of sorting use indexed columns in the ORDER BY clause, as this will result in much faster sorting.
  153. Sorted rows average: %s | ADVISOR_bytime(value,2)
  154. # Joins, scans
  155. rule 'Rate of joins without indexes'
  156. (Select_range_check + Select_scan + Select_full_join) / Uptime
  157. value * 60 * 60 > 1
  158. There are too many joins without indexes.
  159. This means that joins are doing full table scans. Adding indexes for the columns being used in the join conditions will greatly speed up table joins.
  160. Table joins average: %s, this value should be less than 1 per hour | ADVISOR_bytime(value,2)
  161. rule 'Rate of reading first index entry'
  162. Handler_read_first / Uptime
  163. value * 60 * 60 > 1
  164. The rate of reading the first index entry is high.
  165. This usually indicates frequent full index scans. Full index scans are faster than table scans but require lots of CPU cycles in big tables, if those tables that have or had high volumes of UPDATEs and DELETEs, running 'OPTIMIZE TABLE' might reduce the amount of and/or speed up full index scans. Other than that full index scans can only be reduced by rewriting queries.
  166. Index scans average: %s, this value should be less than 1 per hour | ADVISOR_bytime(value,2)
  167. rule 'Rate of reading fixed position'
  168. Handler_read_rnd / Uptime
  169. value * 60 * 60 > 1
  170. The rate of reading data from a fixed position is high.
  171. This indicates that many queries need to sort results and/or do a full table scan, including join queries that do not use indexes. Add indexes where applicable.
  172. Rate of reading fixed position average: %s, this value should be less than 1 per hour | ADVISOR_bytime(value,2)
  173. rule 'Rate of reading next table row'
  174. Handler_read_rnd_next / Uptime
  175. value * 60 * 60 > 1
  176. The rate of reading the next table row is high.
  177. This indicates that many queries are doing full table scans. Add indexes where applicable.
  178. Rate of reading next table row: %s, this value should be less than 1 per hour | ADVISOR_bytime(value,2)
  179. # temp tables
  180. rule 'Different tmp_table_size and max_heap_table_size'
  181. tmp_table_size - max_heap_table_size
  182. value !=0
  183. {tmp_table_size} and {max_heap_table_size} are not the same.
  184. If you have deliberately changed one of either: The server uses the lower value of either to determine the maximum size of in-memory tables. So if you wish to increase the in-memory table limit you will have to increase the other value as well.
  185. Current values are tmp_table_size: %s, max_heap_table_size: %s | ADVISOR_formatByteDown(tmp_table_size, 2, 2), ADVISOR_formatByteDown(max_heap_table_size, 2, 2)
  186. rule 'Percentage of temp tables on disk' [Created_tmp_tables + Created_tmp_disk_tables > 0]
  187. Created_tmp_disk_tables / (Created_tmp_tables + Created_tmp_disk_tables) * 100
  188. value > 25
  189. Many temporary tables are being written to disk instead of being kept in memory.
  190. Increasing {max_heap_table_size} and {tmp_table_size} might help. However some temporary tables are always being written to disk, independent of the value of these variables. To eliminate these you will have to rewrite your queries to avoid those conditions (Within a temporary table: Presence of a BLOB or TEXT column or presence of a column bigger than 512 bytes) as mentioned in the beginning of an <a href="https://www.facebook.com/note.php?note_id=10150111255065841&comments">Article by the Pythian Group</a>
  191. %s% of all temporary tables are being written to disk, this value should be below 25% | round(value,1)
  192. rule 'Temp disk rate' [!fired('Percentage of temp tables on disk')]
  193. Created_tmp_disk_tables / Uptime
  194. value * 60 * 60 > 1
  195. Many temporary tables are being written to disk instead of being kept in memory.
  196. Increasing {max_heap_table_size} and {tmp_table_size} might help. However some temporary tables are always being written to disk, independent of the value of these variables. To eliminate these you will have to rewrite your queries to avoid those conditions (Within a temporary table: Presence of a BLOB or TEXT column or presence of a column bigger than 512 bytes) as mentioned in the <a href="https://dev.mysql.com/doc/refman/5.5/en/internal-temporary-tables.html">MySQL Documentation</a>
  197. Rate of temporary tables being written to disk: %s, this value should be less than 1 per hour | ADVISOR_bytime(value,2)
  198. #
  199. # MyISAM index cache
  200. rule 'MyISAM key buffer size'
  201. key_buffer_size
  202. value == 0
  203. Key buffer is not initialized. No MyISAM indexes will be cached.
  204. Set {key_buffer_size} depending on the size of your MyISAM indexes. 64M is a good start.
  205. key_buffer_size is 0
  206. rule 'Max % MyISAM key buffer ever used' [key_buffer_size > 0]
  207. Key_blocks_used * key_cache_block_size / key_buffer_size * 100
  208. value < 95
  209. MyISAM key buffer (index cache) % used is low.
  210. You may need to decrease the size of {key_buffer_size}, re-examine your tables to see if indexes have been removed, or examine queries and expectations about what indexes are being used.
  211. max % MyISAM key buffer ever used: %s%, this value should be above 95% | round(value,1)
  212. # Don't fire if above rule fired - we don't need the same advice twice
  213. rule 'Percentage of MyISAM key buffer used' [key_buffer_size > 0 && !fired('Max % MyISAM key buffer ever used')]
  214. ( 1 - Key_blocks_unused * key_cache_block_size / key_buffer_size) * 100
  215. value < 95
  216. MyISAM key buffer (index cache) % used is low.
  217. You may need to decrease the size of {key_buffer_size}, re-examine your tables to see if indexes have been removed, or examine queries and expectations about what indexes are being used.
  218. % MyISAM key buffer used: %s%, this value should be above 95% | round(value,1)
  219. rule 'Percentage of index reads from memory' [Key_read_requests > 0]
  220. 100 - (Key_reads / Key_read_requests * 100)
  221. value < 95
  222. The % of indexes that use the MyISAM key buffer is low.
  223. You may need to increase {key_buffer_size}.
  224. Index reads from memory: %s%, this value should be above 95% | round(value,1)
  225. #
  226. # other caches
  227. rule 'Rate of table open'
  228. Opened_tables / Uptime
  229. value*60*60 > 10
  230. The rate of opening tables is high.
  231. Opening tables requires disk I/O which is costly. Increasing {table_open_cache} might avoid this.
  232. Opened table rate: %s, this value should be less than 10 per hour | ADVISOR_bytime(value,2)
  233. rule 'Percentage of used open files limit'
  234. Open_files / open_files_limit * 100
  235. value > 85
  236. The number of open files is approaching the max number of open files. You may get a "Too many open files" error.
  237. Consider increasing {open_files_limit}, and check the error log when restarting after changing {open_files_limit}.
  238. The number of opened files is at %s% of the limit. It should be below 85% | round(value,1)
  239. rule 'Rate of open files'
  240. Open_files / Uptime
  241. value * 60 * 60 > 5
  242. The rate of opening files is high.
  243. Consider increasing {open_files_limit}, and check the error log when restarting after changing {open_files_limit}.
  244. Opened files rate: %s, this value should be less than 5 per hour | ADVISOR_bytime(value,2)
  245. rule 'Immediate table locks %' [Table_locks_waited + Table_locks_immediate > 0]
  246. Table_locks_immediate / (Table_locks_waited + Table_locks_immediate) * 100
  247. value < 95
  248. Too many table locks were not granted immediately.
  249. Optimize queries and/or use InnoDB to reduce lock wait.
  250. Immediate table locks: %s%, this value should be above 95% | round(value,1)
  251. rule 'Table lock wait rate'
  252. Table_locks_waited / Uptime
  253. value * 60 * 60 > 1
  254. Too many table locks were not granted immediately.
  255. Optimize queries and/or use InnoDB to reduce lock wait.
  256. Table lock wait rate: %s, this value should be less than 1 per hour | ADVISOR_bytime(value,2)
  257. rule 'Thread cache'
  258. thread_cache_size
  259. value < 1
  260. Thread cache is disabled, resulting in more overhead from new connections to MySQL.
  261. Enable the thread cache by setting {thread_cache_size} > 0.
  262. The thread cache is set to 0
  263. rule 'Thread cache hit rate %' [thread_cache_size > 0]
  264. 100 - Threads_created / Connections
  265. value < 80
  266. Thread cache is not efficient.
  267. Increase {thread_cache_size}.
  268. Thread cache hitrate: %s%, this value should be above 80% | round(value,1)
  269. rule 'Threads that are slow to launch' [slow_launch_time > 0]
  270. Slow_launch_threads
  271. value > 0
  272. There are too many threads that are slow to launch.
  273. This generally happens in case of general system overload as it is pretty simple operations. You might want to monitor your system load carefully.
  274. %s thread(s) took longer than %s seconds to start, it should be 0 | value, slow_launch_time
  275. rule 'Slow launch time'
  276. slow_launch_time
  277. value > 2
  278. Slow_launch_time is above 2s.
  279. Set {slow_launch_time} to 1s or 2s to correctly count threads that are slow to launch.
  280. slow_launch_time is set to %s | value
  281. #
  282. #Connections
  283. rule 'Percentage of used connections'
  284. Max_used_connections / max_connections * 100
  285. value > 80
  286. The maximum amount of used connections is getting close to the value of {max_connections}.
  287. Increase {max_connections}, or decrease {wait_timeout} so that connections that do not close database handlers properly get killed sooner. Make sure the code closes database handlers properly.
  288. Max_used_connections is at %s% of max_connections, it should be below 80% | round(value,1)
  289. rule 'Percentage of aborted connections'
  290. Aborted_connects / Connections * 100
  291. value > 1
  292. Too many connections are aborted.
  293. Connections are usually aborted when they cannot be authorized. <a href="https://www.percona.com/blog/2008/08/23/how-to-track-down-the-source-of-aborted_connects/">This article</a> might help you track down the source.
  294. %s% of all connections are aborted. This value should be below 1% | round(value,1)
  295. rule 'Rate of aborted connections'
  296. Aborted_connects / Uptime
  297. value * 60 * 60 > 1
  298. Too many connections are aborted.
  299. Connections are usually aborted when they cannot be authorized. <a href="https://www.percona.com/blog/2008/08/23/how-to-track-down-the-source-of-aborted_connects/">This article</a> might help you track down the source.
  300. Aborted connections rate is at %s, this value should be less than 1 per hour | ADVISOR_bytime(value,2)
  301. rule 'Percentage of aborted clients'
  302. Aborted_clients / Connections * 100
  303. value > 2
  304. Too many clients are aborted.
  305. Clients are usually aborted when they did not close their connection to MySQL properly. This can be due to network issues or code not closing a database handler properly. Check your network and code.
  306. %s% of all clients are aborted. This value should be below 2% | round(value,1)
  307. rule 'Rate of aborted clients'
  308. Aborted_clients / Uptime
  309. value * 60 * 60 > 1
  310. Too many clients are aborted.
  311. Clients are usually aborted when they did not close their connection to MySQL properly. This can be due to network issues or code not closing a database handler properly. Check your network and code.
  312. Aborted client rate is at %s, this value should be less than 1 per hour | ADVISOR_bytime(value,2)
  313. #
  314. # InnoDB
  315. rule 'Is InnoDB disabled?' [PMA_MYSQL_INT_VERSION < 50600]
  316. have_innodb
  317. value != "YES"
  318. You do not have InnoDB enabled.
  319. InnoDB is usually the better choice for table engines.
  320. have_innodb is set to 'value'
  321. rule 'InnoDB log size' [innodb_buffer_pool_size > 0]
  322. innodb_log_file_size / innodb_buffer_pool_size * 100
  323. value < 20 && innodb_log_file_size / (1024 * 1024) < 256
  324. The InnoDB log file size is not an appropriate size, in relation to the InnoDB buffer pool.
  325. Especially on a system with a lot of writes to InnoDB tables you should set {innodb_log_file_size} to 25% of {innodb_buffer_pool_size}. However the bigger this value, the longer the recovery time will be when database crashes, so this value should not be set much higher than 256 MiB. Please note however that you cannot simply change the value of this variable. You need to shutdown the server, remove the InnoDB log files, set the new value in my.cnf, start the server, then check the error logs if everything went fine. See also <a href="https://mysqldatabaseadministration.blogspot.com/2007/01/increase-innodblogfilesize-proper-way.html">this blog entry</a>
  326. Your InnoDB log size is at %s% in relation to the InnoDB buffer pool size, it should not be below 20% | round(value,1)
  327. rule 'Max InnoDB log size' [innodb_buffer_pool_size > 0 && innodb_log_file_size / innodb_buffer_pool_size * 100 < 30]
  328. innodb_log_file_size / (1024 * 1024)
  329. value > 256
  330. The InnoDB log file size is inadequately large.
  331. It is usually sufficient to set {innodb_log_file_size} to 25% of the size of {innodb_buffer_pool_size}. A very big {innodb_log_file_size} slows down the recovery time after a database crash considerably. See also <a href="https://www.percona.com/blog/2006/07/03/choosing-proper-innodb_log_file_size/">this Article</a>. You need to shutdown the server, remove the InnoDB log files, set the new value in my.cnf, start the server, then check the error logs if everything went fine. See also <a href="https://mysqldatabaseadministration.blogspot.com/2007/01/increase-innodblogfilesize-proper-way.html">this blog entry</a>
  332. Your absolute InnoDB log size is %s MiB | round(value,1)
  333. rule 'InnoDB buffer pool size' [system_memory > 0]
  334. innodb_buffer_pool_size / system_memory * 100
  335. value < 60
  336. Your InnoDB buffer pool is fairly small.
  337. The InnoDB buffer pool has a profound impact on performance for InnoDB tables. Assign all your remaining memory to this buffer. For database servers that use solely InnoDB as storage engine and have no other services (e.g. a web server) running, you may set this as high as 80% of your available memory. If that is not the case, you need to carefully assess the memory consumption of your other services and non-InnoDB-Tables and set this variable accordingly. If it is set too high, your system will start swapping, which decreases performance significantly. See also <a href="https://www.percona.com/blog/2007/11/03/choosing-innodb_buffer_pool_size/">this article</a>
  338. You are currently using %s% of your memory for the InnoDB buffer pool. This rule fires if you are assigning less than 60%, however this might be perfectly adequate for your system if you don't have much InnoDB tables or other services running on the same machine. | value
  339. #
  340. # other
  341. rule 'MyISAM concurrent inserts'
  342. concurrent_insert
  343. value === 0 || value === 'NEVER'
  344. Enable {concurrent_insert} by setting it to 1
  345. Setting {concurrent_insert} to 1 reduces contention between readers and writers for a given table. See also <a href="https://dev.mysql.com/doc/refman/5.5/en/concurrent-inserts.html">MySQL Documentation</a>
  346. concurrent_insert is set to 0
  347. # INSERT DELAYED USAGE
  348. #Delayed_errors 0
  349. #Delayed_insert_threads 0
  350. #Delayed_writes 0
  351. #Not_flushed_delayed_rows