由于 WHERE 过滤器,来自多个表的 MySQL 请求变慢
我使用请求从 10 个表中选择数据,最后我有 WHERE 和 2 个条件 第一个很简单,但第二个即使没有返回结果,速度也会大大减慢。
AND (eligible_users.id IS NULL OR
((eligible_users.program = 3 AND eligible_users.status = 0)
OR eligible_users.status = 35))
当我删除它时,页面加载速度非常快,是否有某种方法可以使其更快,但仍然保留此过滤器,因为我需要它。
I am using request to select data from 10 tables and at the end i have WHERE and 2 conditions
first one is simple but with second one it slows down dramatically even when there is no results returned.
AND (eligible_users.id IS NULL OR
((eligible_users.program = 3 AND eligible_users.status = 0)
OR eligible_users.status = 35))
When i remove it, page loads much fast, is there some way to make it faster but still keep this filter because i need it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查询中有 3 个 OR 语句,尝试将它们拆分为 1 个或多个联合,如下所示:
You have 3 OR statements in the query, try splitting them into 1 or more unions like so:
添加两个索引,一个用于程序,一个用于状态,可能会大大加快速度。
Adding two indexes, one for program and one for status would probably speed things up nicely.