1. 查询
1-1 group by 比distinct 快
[SQL]select driver_id from XXX where created_time > ‘2017-12-27 00:00:00‘ and created_time<‘2017-12-28 00:00:00‘ group by driver_id
受影响的行: 0
时间: 0.418s
=============
[SQL]select DISTINCT(driver_id) from XXX where created_time > ‘2017-12-27 00:00:00‘ and created_time<‘2017-12-28 00:00:00‘
受影响的行: 0
时间: 0.556s
1-2 where 条件顺序 先过滤掉最多的、过滤最快的(int 比varchar快 比timestamp快)
[SQL]select driver_id,integral,source,city_id from XXX where created_time > ‘2017-12-27 00:00:00‘ and created_time<‘2017-12-28 00:00:00‘ and driver_id=216654
受影响的行: 0
时间: 0.030s
==========
[SQL]select driver_id,integral,source,city_id from XXX where driver_id=216654 and created_time > ‘2017-12-27 00:00:00‘ and created_time<‘2017-12-28 00:00:00‘
受影响的行: 0
时间: 0.017s