本文共 720 字,大约阅读时间需要 2 分钟。
我想从entrytable中选择列文本的内容.
EXPLAIN SELECT text
FROM entrytable
WHERE user = 'username' &&
`status` = '1' && (
`status_spam_user` = 'no_spam'
|| (
`status_spam_user` = 'neutral' &&
`status_spam_system` = 'neutral'
)
)
ORDER BY datum DESC
LIMIT 6430 , 10
该表有三个指数:
> index_user(用户)
> index_datum(datum)
> index_status_mit_spam(status,status_spam_user,status_spam_system)
EXPLAIN结果是:
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE entrytable ref index_user,index_status_mit_spam index_user 32 const 7800 Using where; Using filesort
> might_keys是MySQL可能想要使用的索引并键入MySQL实际使用的索引吗?
>为什么不使用索引index_status_mit_spam?在查询中,列的顺序与索引中的顺序相同,…
>为什么索引index_datum不用于ORDER BY?
>如何优化表索引或查询? (上面的查询需要最多3秒钟,表中有大约一百万个条目)
转载地址:https://blog.csdn.net/weixin_34007963/article/details/113304320 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!