maxc1017 发表于 2018-9-28 10:30:50

MySQL 常用SQL优化

三.优化GROUP BY语句:  1.如果查询包括GROUP BY但用户想要避免排序结果的消耗,则可以指定ORDER BY NULL禁止排序:

  例:mysql > explain select>  *********************************** 1.row **********************************

  >  select_type: SIMPLE
  table: sales2
  type: ALL
  possible_keys: NULL
  key: NULL
  key_len: NULL
  ref: NULL
  rows: 1000
  Extra: Using temporary ; Using Filesort
  1 row in set (0.00 sec)

  mysql > explain select>  *********************************** 1.row **********************************

  >  select_type: SIMPLE
  table: sales2
  type: ALL
  possible_keys: NULL
  key: NULL
  key_len: NULL
  ref: NULL
  rows: 1000
  Extra: Using temporary
  1 row in set (0.00 sec)

页: [1]
查看完整版本: MySQL 常用SQL优化