網站瓶頸分析—MYSQL效能分析

來源:互聯網
上載者:User

標籤:

一、關於慢查詢設定和分析

尋找慢查詢參數

mysql> show variables like ‘long%‘;+-----------------+----------+| Variable_name   | Value    |+-----------------+----------+| long_query_time | 10.000000 |+-----------------+----------+
mysql> show variables like ‘slow%‘;+---------------------+--------------------------------+| Variable_name       | Value                          |+---------------------+--------------------------------+| slow_launch_time    | 2                              || slow_query_log      | OFF                            || slow_query_log_file | /var/lib/mysql/ubuntu-slow.log |+---------------------+--------------------------------+
mysql> show variables like ‘%queries%‘;+-------------------------------+-------+| Variable_name                 | Value |+-------------------------------+-------+| log_queries_not_using_indexes | OFF   || log_slow_queries              | ON    |+-------------------------------+-------+

設定慢查詢參數(作者建議設定為1s)

mysql>  set global long_query_time=1;
mysql> set global slow_query_log=‘ON‘;

 

有些朋友除了設定以上的還會將查詢中未帶索引的語句也設定為on(即log_queries_not_using_indexes),大家可以根據當前的需求來確定是否需要增加。

這樣大家就可以根據相應的日誌去進行最佳化了,當然以上這塊還是主要針對mysql語句進行最佳化

 

二、show processlist、show full processlist查看和分析

 show processlist:主要有以下幾列

+----------+------+-----------+------+---------+------+-------+------------------+| Id       | User | Host      | db   | Command | Time | State | Info             |+----------+------+-----------+------+---------+------+-------+------------------+

 

除了一中進行一個日誌的最佳化外,當然show processlist也是一個方式,如果mysql進程一直處於一個較高的負載的時候,show processlist也是一個不錯的選擇,詳細的參數簡介我就不介紹了,相信網上還是有很多的資料的

 

網站瓶頸分析—MYSQL效能分析

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.