lvhaizhen 2019-06-04 10:47 采纳率: 0%
浏览 365

mysql order by 是怎么把临时表优化掉

EXPLAIN SELECT o.*,a.account_name,a.mobile FROM
(SELECT * FROM m_order_reviewed WHERE is_reviewed = -1 AND is_delete=0) AS o
LEFT JOIN m_account AS a ON o.user_id=a.id INNER JOIN
(SELECT material_code FROM m_material_purchase WHERE purchaser = 2349 AND is_delete = 0)
b ON o.material_code = b.material_code order by o.id limit 0,10图片说明

显示出现了临时表
id 和 gmt_modified 都加上索引了

  • 写回答

1条回答 默认 最新

  • 还记不记得、 2021-08-17 12:23
    关注
    
    SELECT
        o.*,
        a.house_id,
        a.mobile 
    FROM
        ( SELECT * FROM m_order_reviewed WHERE is_reviewed = - 1 AND is_delete = 0 ORDER BY id ) AS o
        LEFT JOIN m_account AS a ON o.user_id = a.id
        INNER JOIN ( SELECT material_code FROM m_material_purchase WHERE purchaser = 2349 AND is_delete = 0 ) b USING ( material_code ) 
        LIMIT 0,10
    

    望采纳!!!

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料