這篇文章將為大家詳細(xì)講解有關(guān)MySQL慢查詢的奇異事件有哪些,小編覺得挺實(shí)用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
創(chuàng)新互聯(lián)致力于互聯(lián)網(wǎng)品牌建設(shè)與網(wǎng)絡(luò)營銷,包括網(wǎng)站建設(shè)、網(wǎng)站設(shè)計、SEO優(yōu)化、網(wǎng)絡(luò)推廣、整站優(yōu)化營銷策劃推廣、電子商務(wù)、移動互聯(lián)網(wǎng)營銷等。創(chuàng)新互聯(lián)為不同類型的客戶提供良好的互聯(lián)網(wǎng)應(yīng)用定制及解決方案,創(chuàng)新互聯(lián)核心團(tuán)隊10多年專注互聯(lián)網(wǎng)開發(fā),積累了豐富的網(wǎng)站經(jīng)驗(yàn),為廣大企業(yè)客戶提供一站式企業(yè)網(wǎng)站建設(shè)服務(wù),在網(wǎng)站建設(shè)行業(yè)內(nèi)樹立了良好口碑。
打開mysql慢查詢?nèi)罩荆l(fā)現(xiàn)有很多sql查詢時間很短,明顯不到0.01s的sql竟然也在慢日志查詢里面,日志詳細(xì)情況如下:
# User@Host: otterpro[otterpro] @ [172.22.53.122] Id: 2061
# Schema: otter Last_errno: 0 Killed: 0
# Query_time: 0.000559 Lock_time: 0.000080 Rows_sent: 3 Rows_examined: 327 Rows_affected: 0
# Bytes_sent: 755
SET timestamp=1512715920;
select ID,NODE_ID,PIPELINE_ID,LOCATION,GMT_CREATE,GMT_MODIFIED from PIPELINE_NODE_RELATION where NODE_ID = 74 ORDER BY ID DESC;
# Time: 171208 14:52:08
# User@Host: otterpro[otterpro] @ [172.22.53.122] Id: 2061
# Schema: otter Last_errno: 0 Killed: 0
# Query_time: 0.000214 Lock_time: 0.000110 Rows_sent: 2 Rows_examined: 2 Rows_affected: 0
# Bytes_sent: 821
SET timestamp=1512715928;
select ID,CLUSTER_NAME,SERVER_LIST,DESCRIPTION,GMT_CREATE,GMT_MODIFIED from AUTOKEEPER_CLUSTER ORDER BY ID ASC;
有點(diǎn)懷疑再次查看了參數(shù):
mysql> show global status like '%slow_queries%';
+---------------+---------+
| Variable_name | Value |
+---------------+---------+
| Slow_queries | 6055683 |
+---------------+---------+
mysql> show variables like '%slow_query_log%';
+------------------------------------+--------------------------------+
| Variable_name | Value |
+------------------------------------+--------------------------------+
| slow_query_log | ON |
| slow_query_log_always_write_time | 10.000000 |
| slow_query_log_file | /data/mysql/13306/tmp/slow.log |
| slow_query_log_timestamp_always | OFF |
| slow_query_log_timestamp_precision | second |
| slow_query_log_use_global_control | |
+------------------------------------+--------------------------------+
6 rows in set (0.01 sec)
mysql> show variables like 'long_query_time';
+-----------------+----------+
| Variable_name | Value |
+-----------------+----------+
| long_query_time | 0.100000 |
+-----------------+----------+
1 row in set (0.00 sec)
mysql> show global variables like '%general%';
+------------------+--------------------------------+
| Variable_name | Value |
+------------------+--------------------------------+
| general_log | OFF |
| general_log_file | /data/mysql/13306/tmp/file.sql |
+------------------+--------------------------------+
2 rows in set (0.00 sec)
log-queries-not-using-indexes
如果運(yùn)行的SQL語句沒有使用索引,則mysql數(shù)據(jù)庫同樣會將這條SQL語句記錄到慢查詢?nèi)罩疚募小?/p>
關(guān)于“mysql慢查詢的奇異事件有哪些”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。