Get the App
SLTechnology News&Howtos  ›  Database  › 

Example Analysis of MySQL slow query Log not printed

Shulou Source: shulou.com Published: 2022-05-31 16:01:52 11月26日 Update

This article is to share with you the content of the example analysis that the MySQL slow query log is not printed. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Test environment modifies long_query_time=0.2

The slow query log does not take effect when executing the following query

Mysql > select sleep (5)

+-+

| | sleep (5) | |

+-+

| | 0 |

+-+

1 row in set (5.00 sec)

⑴ then checks the parameters

Mysql > show variables like'% query%'

+-+ +

| | Variable_name | Value |

+-+ +

| | binlog_rows_query_log_events | OFF |

| | ft_query_expansion_limit | 20 |

| | have_query_cache | YES |

| | long_query_time | 1.000000 | |

| | query_alloc_block_size | 8192 | |

| | query_cache_limit | 0 | |

| | query_cache_min_res_unit | 4096 | |

| | query_cache_size | 0 | |

| | query_cache_type | OFF |

| | query_cache_wlock_invalidate | OFF |

| | query_prealloc_size | 8192 | |

| | slow_query_log | ON |

| | slow_query_log_file | / mlogs/slow1.log |

+-+ +

Found that the configuration is normal.

⑵ then checks the following two parameters

Min_examined_row_limit 、 long-queries-not-using-indexes

Mysql > show variables like 'min_examined_ro%'

+-+ +

| | Variable_name | Value |

+-+ +

| | min_examined_row_limit | 10 | |

+-+ +

1 row in set (0.00 sec)

Mysql > show variables like 'log_queries_not_using_indexes'

+-+ +

| | Variable_name | Value |

+-+ +

| | log_queries_not_using_indexes | OFF |

+-+ +

Then set min_examined_row_limit to 0, and the slow query will record

Two parameters:

Log_queries_not_using_indexes, a query that indicates that the record does not use the index when on, even if it does not exceed the long_query_time

Min_examined_row_limit, which means to record as many queries as possible (when min_examined_row_limit=on)

Reason: select sleep (5) statement query has no record (that is,

Tags: Query log parameter index example analysis two content more article check good practical reason article time environment see knowledge statement Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB macOS Shulou Technology Shulou Information Linux