MySQL中查询表的总行数命令
select count(*) from t;
select count(id) from t;(id为主键)
select count(1) from t;
select count(某普通字段) from t;
show table status的rows字段
总结来说,四种常用查询方式的速度顺序为:count(字段)<count(id)<count(1)<count(*)
MySQL中查询表的总行数命令
select count(*) from t;
select count(id) from t;(id为主键)
select count(1) from t;
select count(某普通字段) from t;
show table status的rows字段
总结来说,四种常用查询方式的速度顺序为:count(字段)<count(id)<count(1)<count(*)