本篇內(nèi)容主要講解“如何定位并優(yōu)化慢查詢sql”,感興趣的朋友不妨來(lái)看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來(lái)帶大家學(xué)習(xí)“如何定位并優(yōu)化慢查詢sql”吧!
10多年的雞澤網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開(kāi)發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。營(yíng)銷型網(wǎng)站的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整雞澤建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無(wú)論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)建站從事“雞澤網(wǎng)站設(shè)計(jì)”,“雞澤網(wǎng)站推廣”以來(lái),每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。
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 | 10.000000 | 查詢時(shí)間 | query_alloc_block_size | 8192 | | query_cache_limit | 1048576 | | query_cache_min_res_unit | 4096 | | query_cache_size | 1048576 | | query_cache_type | OFF | | query_cache_wlock_invalidate | OFF | | query_prealloc_size | 8192 | | slow_query_log | OFF | . 慢日志是否打開(kāi) | slow_query_log_file | /usr/local/mysql/data/tandeMacBook-Pro-slow.log | 慢日志log位置 +------------------------------+-------------------------------------------------+ mysql> set global show_query_log = on; 開(kāi)啟慢查詢?nèi)罩荆ㄗ詈脤?xiě)在配置文件) mysql> set global long_query_time = 1; 設(shè)置慢日志查詢時(shí)間 mysql> show status like "%slow_queries%"; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | Slow_queries | 0 | 慢查詢出現(xiàn)的次數(shù) +---------------+-------+
mysql> explain select * from t_employee where name = "汪燕"; +----+-------------+------------+------------+------+-------------------+-------------------+---------+-------+------+----------+-------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+------------+------------+------+-------------------+-------------------+---------+-------+------+----------+-------+ | 1 | SIMPLE | t_employee | NULL | ref | idx_employee_name | idx_employee_name | 50 | const | 1 | 100.00 | NULL | +----+-------------+------------+------------+------+-------------------+-------------------+---------+-------+------+----------+-------+
到此,相信大家對(duì)“如何定位并優(yōu)化慢查詢sql”有了更深的了解,不妨來(lái)實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!