相关疑难解决方法(0)

MySQL:加入未使用的表时的索引(性能优化问题)

我需要优化以下查询:

SELECT /* [things omitted] */ articles.blogpost_id, articles.id AS articleid
FROM blogposts
JOIN articles ON articles.blogpost_id = blogposts.id
WHERE blogposts.deleted = 0
AND blogposts.title LIKE '%{de}%'
AND blogposts.visible = 1
AND blogposts.date_published <= NOW()
ORDER BY blogposts.date_created DESC
LIMIT 0 , 50
Run Code Online (Sandbox Code Playgroud)

EXPLAIN SELECT 给我以下结果:

id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE articles ALL blogpost_id NULL NULL NULL 6915 Using temporary; Using filesort
1 SIMPLE blogposts eq_ref PRIMARY PRIMARY 4 articles.blogpost_id 1 Using where
Run Code Online (Sandbox Code Playgroud)

为什么它先是文章,然后是博客文章?是因为博客文章有更多条目吗?以及如何改进查询以便文章帖子可以使用索引? …

mysql performance index query optimization

6
推荐指数
1
解决办法
6626
查看次数

标签 统计

index ×1

mysql ×1

optimization ×1

performance ×1

query ×1