1 row in set (0.01 sec)
这里我们用到了MariaDB的虚拟列,并且对虚拟列指定persistent属性,这样就能当成真实的属性来看待了。
行,下来我们利用这个虚拟列来进行查询,不过这样反而简单点,查询语句不需要那么严格了,直接跟普通的语句一样。
MariaDB [t_girl]> explain select count(email) from email_list where email_suffix = '56.com';
+------+-------------+------------+------+------------------+------------------+---------+-------+------+-----------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+------------+------+------------------+------------------+---------+-------+------+-----------------------+
| 1 | SIMPLE | email_list | ref | idx_email_suffix | idx_email_suffix | 103 | const | 1959 | Using index condition |
+------+-------------+------------+------+------------------+------------------+---------+-------+------+-----------------------+
1 row in set (0.02 sec)
查询速度当然也就非常快了。
MariaDB [t_girl]> select count(email) from email_list where email_suffix = '56.com';
+--------------+
| count(email) |
+--------------+
| 1960 |
+--------------+
1 row in set (0.02 sec)