想根据月份查询总数,请问下面两条sql哪个速度会快一点,如果有更好的方案的话,麻烦大神们给出,先谢谢了。
select count(1) from table1 where c_time > ‘2014-10-01 00:00:00’ and c_time < ‘2014-11-01 00:00:00’;
select count(1) from table1 where c_time like ‘2014-10%’;
想根据月份查询总数,请问下面两条sql哪个速度会快一点,如果有更好的方案的话,麻烦大神们给出,先谢谢了。
select count(1) from table1 where c_time > ‘2014-10-01 00:00:00’ and c_time < ‘2014-11-01 00:00:00’;
select count(1) from table1 where c_time like ‘2014-10%’;
4 回答1.5k 阅读✓ 已解决
8 回答1.3k 阅读
3 回答991 阅读✓ 已解决
3 回答1.1k 阅读✓ 已解决
3 回答1.9k 阅读
2 回答1.7k 阅读
1 回答904 阅读✓ 已解决
个人觉得第一种写法效率高,因为like模糊匹配效率是最低的,需要扫表