说明;News2在News的基础上把is_active加上索引。
mysql> select count(*) from News2 where is_active=1;
+----------+
| count(*) |
+----------+
| 7820331 |
+----------+
1 row in set (14.77 sec)
mysql> select count(*) from News2 where is_active=0;
+----------+
| count(*) |
+----------+
| 7797380 |
+----------+
1 row in set (14.56 sec)
mysql> select count(*) from News where is_active=0;
+----------+
| count(*) |
+----------+
| 7797380 |
+----------+
1 row in set (35.20 sec)
mysql> select count(*) from News where is_active=1;
+----------+
| count(*) |
+----------+
| 7820331 |
+----------+
1 row in set (35.12 sec)
本文通过对比两个数据表News和News2在进行相同查询条件下的性能表现,展示了为字段添加索引后对于查询效率的显著提升。实验结果显示,在对is_active字段添加索引后,查询耗时从35秒减少到了约14.5秒。
10万+

被折叠的 条评论
为什么被折叠?



