查看索引:
mysql> show index from user_info; +-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | +-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | user_info | 0 | PRIMARY | 1 | id | A | 6 | NULL | NULL | | BTREE | | | +-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ 1 row in set
查看键:
mysql> show keys from user_info; +-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | +-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | user_info | 0 | PRIMARY | 1 | id | A | 6 | NULL | NULL | | BTREE | | | +-----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ 1 row in set
查看语句的耗时:
mysql> set profiling = 1; Query OK, 0 rows affected mysql> select * from word_list where word like 'b%'; +-----------+-----------------------------------------------+------+ | word | paraphrase | sign | +-----------+-----------------------------------------------+------+ | backward | a. 向后的; ad. 向后 | F | | bar | vt. 1.阻止,不许 2.阻碍,阻塞 n. 酒吧,吧台 | F | | being | n. 1.生物,人 2.存在 | F | | billboard | n. 布告板,揭示栏,广告牌 | F | | billion | num.&n. 十亿 | F | | butterfly | n. 蝴蝶 | F | +-----------+-----------------------------------------------+------+ 6 rows in set mysql> select * from word_list where word like 'c%'; +----------------+----------------------------------+------+ | word | paraphrase | sign | +----------------+----------------------------------+------+ | capital-driven | a. 追求更多资本的 | F | | cartoon | n. 动画片; vt. 为...画漫画 | T | | chart | n. 图,图表 vt. 制图表 | F | | cholesterol | n. 胆固醇 | F | | circuit | n. 电路,一圈,巡回 | F | | civil | a. 国内的,公民的,国民的 | F | | civilization | n. 文明,文化 | F | | classical | a. 古典的 | F | | colonial | a. 殖民地的; n. 殖民地居民 | F | | colonialism | n. 殖民主义 | F | | commercial | a. 商业的; n. 商业广告 | F | | comparison | n. 比较 | F | | competition | n. 比赛,竞争 | F | | competitive | a. 竞争的,比赛的 | F | | compute | 计算 | F | | conference | n. 会议 | F | | confine | v. 限制,闭居; [计算机] 限制 | F | | congress | n. 代表大会,国会,议会;男女性交 | F | | consequence | ad. 因而,所以; n. 结果,后果 | F | | constant | a. 经常的,不变的; n. 常数,恒量 | F | | constantly | ad. 不断地,经常地 | F | | construct | v. 构造,建造,想出 | F | | constructive | a. 建设性的,构造上的,作图的 | F | | consumeristic | adj. 消费主义的 | F | | consumption | n. 消费 | F | | contribution | n. 贡献 | F | | cooperate | vi. 合作,协作,配合 | F | | corporation | n. 公司 | F | | cycle | n. 循环,周期; v. 骑自行车 | F | +----------------+----------------------------------+------+ 29 rows in set mysql> show profiles; +----------+------------+----------------------------------------------+ | Query_ID | Duration | Query | +----------+------------+----------------------------------------------+ | 1 | 0.00065 | select * from word_list where word like 'b%' | | 2 | 0.00047325 | select * from word_list where word like 'c%' | +----------+------------+----------------------------------------------+ 2 rows in set
查看执行语句的详细情况:
mysql> explain select * from word_list where word like 'c%'; +----+-------------+-----------+-------+---------------+---------+---------+------+------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-----------+-------+---------------+---------+---------+------+------+-------------+ | 1 | SIMPLE | word_list | range | PRIMARY | PRIMARY | 92 | NULL | 29 | Using where | +----+-------------+-----------+-------+---------------+---------+---------+------+------+-------------+ 1 row in set
后待补充