这个 sql 如何优化?

下面这个 sql,ci_customer 表有 40w 数据,ci_follow 表有300w 数据,查询速度为 10s。请问是否有方法将这个 sql 优化一下呢。

f.customer_id、f.id、c.id 都是有索引的。

SELECT COUNT(*) AS `numrows`
FROM (`ci_follow` as f)
right join ci_customer as c on c.id = f.customer_id
WHERE (1 = 1)
  and f.isdel = 0
  and c.isdel = 0
order by f.id desc;

explain如下

阅读 482
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进