(1).select * from t;
(2).select t.id from t;
(3).select 1 from t;
(4).select count(0) from t;
在查询sql语句中,只做判断是否有数据的话,上面的这4中sql语句的速度的话是(1)<(2)<(3)<=(4)。
什么情况下(3)=(4)的呢?
在查询的结果只有一条数据的时候两者是相等的效率,当查询出来的数据大于一条时。(3)的时间大于(4)的时间。
(1).select * from t;
(2).select t.id from t;
(3).select 1 from t;
(4).select count(0) from t;
在查询sql语句中,只做判断是否有数据的话,上面的这4中sql语句的速度的话是(1)<(2)<(3)<=(4)。
什么情况下(3)=(4)的呢?
在查询的结果只有一条数据的时候两者是相等的效率,当查询出来的数据大于一条时。(3)的时间大于(4)的时间。