MySQL Porfiling解析

5120 ワード

目次:
  • MySQL Porfiling解析
  • 前言
  • フロー
  • 意味分析
  • 関連外鎖
  • profilingの学習材料
  • を別途添付


    MySQL Porfiling解析
    前言
    あるsqlのパフォーマンスを分析する場合に使用します.Profilingはmysql 5から.0.3バージョン以降はオープンしています.Profileを起動すると、エラーを含むすべてのクエリが記録されます.セッションを閉じるかset profiling=0で閉じます.(profiling_history_sizeパラメータを0に設定すると、MySQLを閉じるprofiling効果もあります.)
    SQLの実行ステータス、System lockとTable lockの時間などを問い合わせるためのツールです.
    1つの文を位置決めするためのI/O消費とCPU消費は非常に重要です.(SQL文の実行に消費される最大2つのリソースはIOとCPUです)
    -mysql 5.7以降、profile情報は徐々に廃棄され、mysqlはperformance schemaの使用を推奨する
    プロセス
    簡易プロセスは次のようになります.
    set profiling=1;                //    
    
    run your sql1;
    
    run your sql2;
    
    show profiles;                  //  sql1,sql2     
    
    show profile for query 1;       //  sql1     
    
    show profile ALL for query 1;   //  sql1       【   i/o cpu,            】
    
    set profiling=0;                //    
    

    いみぶんせき
  • show profile ALL for query 1;
  • +----------------------+----------+----------+------------+
    "Status": "query end",   
    "Duration": "1.751142",     
    "CPU_user": "0.008999", cpu  
    "CPU_system": "0.003999", cpu  
    "Context_voluntary": "98",        
    "Context_involuntary": "0",        
    "Block_ops_in": "8",        
    "Block_ops_out": "32",        
    "Messages_sent": "0",     
    "Messages_received": "0",     
    "Page_faults_major": "0",      
    "Page_faults_minor": "0",      
    "Swaps": "0",     
    "Source_function": "mysql_execute_command",    
    "Source_file": "sql_parse.cc",    
    "Source_line": "4465"     
    +----------------------+----------+----------+------------+
  • show profile for query 1;
  • +----------------------+----------+----------+------------+
    starting:  
    checking permissions:    
    Opening tables:   
    init :    
    System lock :   
    optimizing :   
    statistics :   
    preparing :  
    executing :  
    Sending data :    
    Sorting result :  
    end :  
    query end :     
    closing tables :     /  TMP  
    freeing items :     
    cleaning up :  
    +----------------------+----------+----------+------------+

    相関外鎖
    profilingの学習材料を添付します
  • profilingベースhttp://www.tuicool.com/articles/ZFrUzia http://www.xaprb.com/blog/2006/10/12/how-to-profile-a-query-in-mysql/ http://www.xaprb.com/blog/2006/10/15/a-case-study-in-profiling-queries-in-mysql/ http://www.xaprb.com/blog/2006/10/17/mysql-profiling-case-study-part-2/
  • profilingステップアップhttp://www.mysqlperformanceblog.com/2009/01/19/profiling-mysql-stored-routines/ http://www.mysqlperformanceblog.com/2008/05/18/wanted-better-memory-profiling-for-mysql/maatkit–perldoc mk-query-profiler
  • profilingプレミアムhttp://dev.mysql.com/tech-resources/articles/pro-mysql-ch6.html http://dev.mysql.com/tech-resources/articles/using-new-query-profiler.html
  • profiling骨灰級http://www.scribd.com/doc/2669413/DTrace-and-MySQL-Presentation http://forge.mysql.com/wiki/Using_DTrace_with_MySQL http://wikis.sun.com/display/BluePrints/Optimizing+MySQL+Database+Application+Performan http://blog.csdn.net/lihuayong/article/details/42044593

  • 転載:住所