Home  >  Q&A  >  body text

mysql - 慢查询如何优化

mysql慢查询语句该如何优化

SELECT * FROM `x_order` LEFT JOIN x_goods ON x_goods.goods_id = x_order.order_goodsid WHERE `order_isdelete` = 0 AND `goods_type` = 0 GROUP BY order_no
黄舟黄舟2741 days ago594

reply all(3)I'll reply

  • PHPz

    PHPz2017-04-17 14:52:11

    Build an index
    order_isdelete goods_type order_no goods_id
    Consider how to build an index to optimize the query for these fields.

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 14:52:11

    Where group by select, try to do it on the index

    reply
    0
  • 阿神

    阿神2017-04-17 14:52:11

    1. Try not to use JOIN and migrate functions from SQL to code level processing

    2. Index

    reply
    0
  • Cancelreply