$ select count(0) from [表名] where CreationDate > '2017-01-01'
MySQL
TiDB
math_stackexchange.users
0.063 sec
0.219 sec
math_stackexchange.comments
0.422 sec
0.813 sec
stackoverflow.users
0.922 sec
1.312 sec
stackoverflow.comments
2.891 sec
1.437 sec
无索引
1 2 3 4
$ select count(0) from math_stackexchange.users where views > 10 $ select count(0) from math_stackexchange.comments where score > 3 $ select count(0) from stackoverflow.users where views > 10 $ select count(0) from stackoverflow.comments where score > 3
MySQL
TiDB
math_stackexchange.users
0.203 sec
0.484 sec
math_stackexchange.comments
2.219 sec
1.297 sec
stackoverflow.users
4.312 sec
2.297 sec
stackoverflow.comments
61.42 sec
11.313 sec
连表查询
1 2
$ select count(0) from math_stackexchange.comments as a join math_stackexchange.users as b on a.UserId = b.Id where a.CreationDate > '2017-01-01' and b.views > 10 $ select count(0) from stackoverflow.comments as a join stackoverflow.users as b on a.UserId = b.Id where a.CreationDate > '2017-01-01' and b.views > 10