mysql关于order by效率很慢的问题
select
ts.uploadDate,
tv.carNumber as CarNumber,
tv.id as VinId,tu.nick as Nick,
tu.userName as UserName,
tu.id as UserId,
ts.id as Id
from t_travel_data_summarize ts
left outer join t_vin tv on ts.vinId = tv.id
left join t_user tu on ts.userId = tu.id
where Length(tv.carNumber) > 7 and tv.carNumber !='无车牌' and tv.carNumber != '测试车'
group by ts.vinId order by ts.id desc limit 6
rows
1 SIMPLE ts index index_vinid PRIMARY 4 6 Using temporary
1 SIMPLE tv eq_ref PRIMARY PRIMARY 4 qcwp_auto_data.ts.VinId 1 Using where
1 SIMPLE tu eq_ref PRIMARY PRIMARY 4 qcwp_auto_data.ts.UserId 1
查询时间接近1分钟,把order by去掉瞬间出来,有大神可以解答下吗
ts.uploadDate,
tv.carNumber as CarNumber,
tv.id as VinId,tu.nick as Nick,
tu.userName as UserName,
tu.id as UserId,
ts.id as Id
from t_travel_data_summarize ts
left outer join t_vin tv on ts.vinId = tv.id
left join t_user tu on ts.userId = tu.id
where Length(tv.carNumber) > 7 and tv.carNumber !='无车牌' and tv.carNumber != '测试车'
group by ts.vinId order by ts.id desc limit 6
rows
1 SIMPLE ts index index_vinid PRIMARY 4 6 Using temporary
1 SIMPLE tv eq_ref PRIMARY PRIMARY 4 qcwp_auto_data.ts.VinId 1 Using where
1 SIMPLE tu eq_ref PRIMARY PRIMARY 4 qcwp_auto_data.ts.UserId 1
查询时间接近1分钟,把order by去掉瞬间出来,有大神可以解答下吗
...全文
相关推荐
mysql优化取随机数据慢的方法
mysql取随机数据慢,怎么办?下面小编与大家一起来看看mysql取随机数据慢优化的过程。
Mysql limit 优化,百万至千万级快速分页 复合索引的引用并应用于轻量级框架
MySql 这个数据库绝对是适合dba级的高手去玩的,一般做一点1万篇新闻的小型系统怎么写都可以,用xx框架可以实现快速开发。可是数据量到了10万,百万至千万,他的性能还能那么高吗?一点小小的失误,可能造成整个系统的改写,甚至更本系统无法正常运行!好了,不那么多废话了。用事实说话,看例子: 数据表 collect ( id, title ,info ,vtype) 就这4个字段,其中 title 用定长,info 用text, id 是逐渐,vtype是tinyint,vtype是索引。这是一个基本的新闻系统的简单模型。现在往里面填充数据,填充10万篇新闻。 最后collect 为 10万条记
mysql limit分页优化详细介绍
MySQL最常用也最需要优化的就是limit,MySQL的limit给分页带来了极大的方便,但数据量一大的时候,limit的性能就急剧下降,需要的朋友可以参考下
mysql实现随机查询经验谈
官方文档中进行说明:Order By和RAND()连用,会多次扫描表,导致速度变慢,下面看下一些测试详解
MYSQL随机抽取查询 MySQL Order By Rand()效率问题
MYSQL随机抽取查询:MySQL Order By Rand()效率问题一直是开发人员的常见问题,俺们不是DBA,没有那么牛B,所只能慢慢研究咯,最近由于项目问题,需要大概研究了一下MYSQL的随机抽取实现方法


高性能WEB开发
