300万条数据,3张表联合查询 select top 8 要8秒多,怎么提高查询效率?
select top 8 n.id,n.title,n.createTime,c.[name],count(com.id) as comCount,c.id as caId
from news n
left join category c on n.caId = c.id --inner join速度慢
left join comment com on com.newsId = n.id
group by n.id,n.title,n.createTime,c.[name],c.id
order by comCount desc
总共3张表 news(新闻表),category(分类表),comment(评论表)
-- 100万条数据 2秒多
-- 300万条数据 8秒多
时间有点长,效率态低,怎么解决啊?