您好,欢迎访问一九零五行业门户网

查看mysql的执行计划_MySQL

bitscn.com
查看mysql的执行计划 这条sql执行4分钟,message_message有数据1000w,学写了下mysql的执行计划。
  select * from message_message where id in(select message_id
from message_message_tags where messagetag_id=59885) and (category=9 or category=1)
order by  sum(like_count,favorite_count) desc limit 15;          在开发的过程中随着数据量的增大而感受到数据库的性能比较差从而延伸到响应速度慢,
如果是开发人员很多时候估计是处于一种茫然状态,或者直接交给dba去处理这问题,如果有dba您很幸运,
但是如果没有dba的前提下我们怎么去处理这问题,可能唯一的方法就是看执行计划
(也可以直接用explain sql来分析...):默认情况下mysql的profiling是关闭的,所以首先必须打开profiling sql代码  set profiling=on  mysql> show variables like %profi%;  +------------------------+-------+  | variable_name          | value |  +------------------------+-------+  | profiling              | on    |       show processlist;   查看现在在运行的所有进程列表,在进程列表中我们唯一需要的是id  mysql> show processlist;  +----+------+----------------+-----------+---------+------+-------+-------------  -----+  | id | user | host           | db        | command | time | state | info       |  +----+------+----------------+-----------+---------+------+-------+-------------  -----+  |  3 | root | localhost:2196 | click_log | query   |    0 | null  | show process  list |  +----+------+----------------+-----------+---------+------+-------+-------------  mysql> show profile cpu,memory for query 3;  +--------------------+------------+----------+------------+  | status             | duration   | cpu_user | cpu_system |  +--------------------+------------+----------+------------+  | freeing items      | 0.00001375 |     null |       null |  | logging slow query | 0.00001375 |     null |       null |  | cleaning up        | 0.00000050 |     null |       null |  +--------------------+------------+----------+------------+    show profiles syntax:  show profile [type [, type] ... ]      [for query n]         [limit row_count [offset offset]]  type:      all    | block io    | context switches    | cpu    | ipc    | memory    | page faults    | source    | swaps     作者 san_yun bitscn.com
其它类似信息

推荐信息