全表扫描
mysql> desc select *
from z1 ;
+----+-------------+-------+------------+------+---------------+------+---------+------+-------+----------+-------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-------+------------+------+---------------+------+---------+------+-------+----------+-------+
| 1 | SIMPLE | z1 | NULL | ALL | NULL | NULL | NULL | NULL |
56650 | 100.00 | NULL |
+----+-------------+-------+------------+------+---------------+------+---------+------+-------+----------+-------+
1 row in set, 1 warning (0.00 sec)
第一次:
#0 row_search_mvcc (buf=0x7fff2ccc9380 "\377", mode=PAGE_CUR_G, prebuilt=0x7fff2cd4bb40, match_mode=0, direction=0)
at /root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/row/row0sel.
cc:4479
#1 0x00000000019b3051 in ha_innobase::index_read (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\377", key_ptr=0x0, key_len=0, find_flag=HA_READ_AFTER_KEY)
at /root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/handler/ha_innodb.cc:9104
#2 0x00000000019b4374 in ha_innobase::index_first (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\377")
at /root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/
handler/ha_innodb.cc:9551
#3 0x00000000019b462c in ha_innobase::rnd_next (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\377")
at /root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/handler/ha_innodb.cc:9656
#4 0x0000000000f66fa2 in handler::ha_rnd_next (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\377") at /root/mysql5.7.14/percona-server-5.7.14-7/sql/handler.cc:3099
#5 0x00000000014c61b6 in rr_sequential (info=0x7fff2c0026a0) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/records.cc:520
#6 0x000000000155f2a4 in join_init_read_record (tab=0x7fff2c002650) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:2481
#7 0x000000000155c381 in sub_select (join=0x7fff2c001f70, qep_tab=0x7fff2c002650, end_of_records=false)
at
/root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:1271
#8 0x000000000155bd06 in do_select (join=0x7fff2c001f70) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:944
#9 0x0000000001559bdc in JOIN::exec (this=0x7fff2c001f70) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:199
随后访问:
#0 row_search_mvcc (buf=0x7fff2ccc9380 "\376\n", mode=PAGE_CUR_UNSUPP, prebuilt=0x7fff2cd4bb40, match_mode=0, direction=1)
at /root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/row/
row0sel.cc:4479
#1 0x00000000019b3f50 in ha_innobase::general_fetch (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\376\n", direction=1, match_mode=0)
at /root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/handler/ha_innodb.cc:9425
#2 0x00000000019b4666 in ha_innobase::rnd_next (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\376\n")
at /root/mysql5.7.14/percona-server-5.7.14-7/storage/
innobase/handler/ha_innodb.cc:9664
#3 0x0000000000f67026 in handler::ha_rnd_next (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\376\n") at /root/mysql5.7.14/percona-server-5.7.14-7/sql/handler.cc:3099
#4 0x00000000014c61b6 in rr_sequential (info=0x7fff2c0026a0) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/records.cc:520
#5 0x000000000155c397 in sub_select (join=0x7fff2c001f70, qep_tab=0x7fff2c002650, end_of_records=false)
at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:1274
#6 0x000000000155bd06 in do_select (join=0x7fff2c001f70) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:944
#7 0x0000000001559bdc in JOIN::exec (this=0x7fff2c001f70) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:199
全索引扫描
mysql> desc select a from z1 ;
+----+-------------+-------+------------+-------+---------------+------+---------+------+-------+----------+-------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-------+------------+-------+---------------+------+---------+------+-------+----------+-------------+
| 1 | SIMPLE | z1 | NULL | index | NULL
| a | 5 | NULL | 56650 | 100.00 | Using index |
+----+-------------+-------+------------+-------+---------------+------+---------+------+-------+----------+-------------+
1 row in set, 1 warning (0.00 sec)
第一次:
#0 row_search_mvcc (buf=0x7fff2ccc9380 "\377", mode=PAGE_CUR_G, prebuilt=0x7fff2cd4bb40, match_mode=0, direction=0)
at /root/mysql5.7.14/percona-server-5.7.14
-7/storage/innobase/row/row0sel.cc:4479
#1 0x00000000019b3051 in ha_innobase::index_read (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\377", key_ptr=0x0, key_len=0, find_flag=HA_READ_AFTER_KEY)
at /root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/handler/ha_innodb.cc:9104
#2 0x00000000019b4374 in ha_innobase::index_first (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\377")
at /root/mysql5.7.14/percona-server
-5.7.14-7/storage/innobase/handler/ha_innodb.cc:9551
#3 0x0000000000f686f4 in handler::ha_index_first (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\377") at /root/mysql5.7.14/percona-server-5.7.14-7/sql/handler.cc:3337
#4 0x000000000155f997 in join_read_first (tab=0x7fff2c002578) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:2646
#5 0x000000000155c381 in sub_select (join=0x7fff2c001e98, qep_tab=0x7fff2c002578, end_of_records=false)
at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:1271
#6 0x000000000155bd06 in do_select (join=0x7fff2c001e98) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:944
#7 0x0000000001559bdc in JOIN::exec (this=0x7fff2c001e98) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:199
随后访问:
#0 row_search_mvcc (buf=0x7fff2ccc9380 "\376\n", mode=PAGE_CUR_UNSUPP, prebuilt=0x7fff2cd4bb40, match_mode=0, direction=1)
at /root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/row/row0sel.cc:4479
#1 0x00000000019b3f50 in ha_innobase::general_fetch (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\376\n", direction=1, match_mode=0)
at /root/mysql5.7.14/percona-server-5.7.14-7/
storage/innobase/handler/ha_innodb.cc:9425
#2 0x00000000019b4261 in ha_innobase::index_next (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\376\n")
at /root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/handler/ha_innodb.cc:9503
#3 0x0000000000f680d8 in handler::ha_index_next (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\376\n") at /root/mysql5.7.14/percona-server-5.7.14-7/sql/handler.cc:3269
#4 0x000000000155fa02 in join_read_next (info=0x7fff2c0025c8) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:2660
#5 0x000000000155c397 in sub_select (join=0x7fff2c001e98, qep_tab=0x7fff2c002578, end_of_records=false)
at /root
/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:1274
#6 0x000000000155bd06 in do_select (join=0x7fff2c001e98) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:944
#7 0x0000000001559bdc in JOIN::exec (this=0x7fff2c001e98) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:199
索引ref const
mysql> desc select * from z1 where a=10;
+----+-------------+-------+------------+------+---------------+------+---------+-------+-------+----------+-------+
| id | select_type |
table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-------+------------+------+---------------+------+---------+-------+-------+----------+-------+
| 1 | SIMPLE | z1 | NULL | ref | a | a | 5 | const | 28325 | 100.00 | NULL |
+----+-------------+-------+------------+------+---------------+------+---------+-------+-------+----------+-------+
1 row in set, 1 warning (0.00 sec)
初次访问:
#0 row_search_mvcc (buf=0x7fff2ccc9380 "\376\n", mode=PAGE_CUR_GE, prebuilt=0x7fff2cd4bb40, match_mode=1, direction=0)
at /root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/row/row0sel.cc:4479
#1 0x00000000019b3051 in ha_innobase::index_read (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\376\n", key_ptr=0x7fff2cddf0d0 "", key_len=5, find_flag=HA_READ_KEY_EXACT)
at /root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/handler/ha_innodb.cc:9104
#2 0x0000000000f75dc4 in handler::index_read_map (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\376\n", key=0x7fff2cddf0d0 "", keypart_map=1, find_flag=HA_READ_KEY_EXACT)
at /root/mysql5.7.14/percona-server-5.7.14-7/sql/handler.h:2843
#3 0x0000000000f675fa in handler::ha_index_read_map (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\376\n", key=0x7fff2cddf0d0 "", keypart_map=1,
find_flag=HA_READ_KEY_EXACT) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/handler.cc:3183
#4 0x000000000155e9ab in join_read_always_key (tab=0x7fff2cddf1d0) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:2260
#5 0x000000000155c381 in sub_select (join=0x7fff2c002528, qep_tab=0x7fff2cddf1d0, end_of_records=false)
at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:1271
#6 0x000000000155bd06 in do_select (join=0x7fff2c002528) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:944
#7 0x0000000001559bdc in JOIN::exec (this=0x7fff2c002528) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:199
随后访问
#0 row_search_mvcc (buf=0x7fff2ccc9380 "\376\n", mode=PAGE_CUR_UNSUPP, prebuilt=0x7fff2cd4bb40, match_mode=1, direction=1)
at /root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/row/row0sel.cc:4479
#1 0x00000000019b3f50 in ha_innobase::general_fetch (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\376\n", direction=1, match_mode=1)
at /root/mysql5.7.14/percona-server
-5.7.14-7/storage/innobase/handler/ha_innodb.cc:9425
#2 0x00000000019b42b5 in ha_innobase::index_next_same (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\376\n", key=0x7fff2cddf0d0 "", keylen=5)
at /root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/handler/ha_innodb.cc:9519
#3 0x0000000000f68e37 in handler::ha_index_next_same (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\376\n", key=0x7fff2cddf0d0 "", keylen=5)
at /root/mysql5.7.14
/percona-server-5.7.14-7/sql/handler.cc:3407
#4 0x000000000155ebd4 in join_read_next_same (info=0x7fff2cddf220) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:2319
#5 0x000000000155c397 in sub_select (join=0x7fff2c002528, qep_tab=0x7fff2cddf1d0, end_of_records=false)
at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:1274
#6 0x000000000155bd06 in do_select (join=0x7fff2c002528) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:944
#7 0x0000000001559bdc in JOIN::exec (this=0x7fff2c002528) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:199
索引 range
mysql> desc select * from z1 force index(a) where a>=10 and a<12;
+----+-------------+-------+------------+-------+---------------+------+---------+------+-------+----------+-----------------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-------+------------+-------+---------------+------+---------+------+-------+----------+-----------------------+
| 1 | SIMPLE | z1 | NULL | range | a | a | 5 | NULL | 28325 | 100.00 | Using index condition |
+----+-------------+-------+------------+-------+---------------+------+---------+------+-------+----------+-----------------------+
1 row in set, 1 warning (0.03 sec)
初次访问:
0 row_search_mvcc
(buf=0x7fff2ccc9380 "\377", mode=PAGE_CUR_GE, prebuilt=0x7fff2cd4bb40, match_mode=0, direction=0)
at /root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/row/row0sel.cc:4479
#1 0x00000000019b3051 in ha_innobase::index_read (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\377", key_ptr=0x7fff2ce21bc0 "", key_len=5, find_flag=HA_READ_KEY_OR_NEXT)
at /root/mysql5.
7.14/percona-server-5.7.14-7/storage/innobase/handler/ha_innodb.cc:9104
#2 0x0000000000f75dc4 in handler::index_read_map (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\377", key=0x7fff2ce21bc0 "", keypart_map=1, find_flag=HA_READ_KEY_OR_NEXT)
at /root/mysql5.7.14/percona-server-5.7.14-7/sql/handler.h:2843
#3 0x0000000000f675fa in handler::ha_index_read_map (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\377", key=0x7fff2ce21bc0 "", keypart_map=1,
find_flag=HA_READ_KEY_OR_NEXT) at /
root/mysql5.7.14/percona-server-5.7.14-7/sql/handler.cc:3183
#4 0x0000000000f7186e in handler::read_range_first (this=0x7fff2cd32480, start_key=0x7fff2cd32568, end_key=0x7fff2cd32588, eq_range_arg=false, sorted=false)
at /root/mysql5.7.14/percona-server-5.7.14-7/sql/handler.cc:7565
#5 0x0000000000f6f7cd in handler::multi_range_read_next (this=0x7fff2cd32480, range_info=0x7ffff03598c0)
at /root/mysql5
.7.14/percona-server-5.7.14-7/sql/handler.cc:6635
#6 0x0000000000f706b7 in DsMrr_impl::dsmrr_next (this=0x7fff2cd328f0, range_info=0x7ffff03598c0) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/handler.cc:7019
#7 0x00000000019c6210 in ha_innobase::multi_range_read_next (this=0x7fff2cd32480, range_info=0x7ffff03598c0)
at /root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/handler/ha_innodb.cc:21372
#8 0x00000000017904b2 in QUICK_RANGE_SELECT::get_next (this=0x7fff2ccc9760) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/opt_range.cc:11171
#9 0x00000000014c5f56 in rr_quick (info=0x7fff2cddf050) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/records.cc:398
#10 0x000000000155f2a4 in join_init_read_record (tab=0x7fff2cddf000) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:2481
#11 0x000000000155c381 in sub_select (join=0x7fff2cdde4e0, qep_tab=0x7fff2cddf000, end_of_records=false)
at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:1271
#12 0x000000000155bd06 in do_select (join=0x7fff2cdde4e0) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:944
#13 0x0000000001559bdc in JOIN::exec (this=0x7fff2cdde4e0) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:199
随后访问:
#0 row_search_mvcc (buf=0x7fff2ccc9380 "\376\n", mode=PAGE_CUR_UNSUPP, prebuilt=0x7fff2cd4bb40, match_mode=0, direction=1)
at /root/mysql5.
7.14/percona-server-5.7.14-7/storage/innobase/row/row0sel.cc:4479
#1 0x00000000019b3f50 in ha_innobase::general_fetch (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\376\n", direction=1, match_mode=0)
at /root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/handler/ha_innodb.cc:9425
#2 0x00000000019b4261 in ha_innobase::index_next (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\376\n")
at /
root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/handler/ha_innodb.cc:9503
#3 0x0000000000f680d8 in handler::ha_index_next (this=0x7fff2cd32480, buf=0x7fff2ccc9380 "\376\n") at /root/mysql5.7.14/percona-server-5.7.14-7/sql/handler.cc:3269
#4 0x0000000000f719af in handler::read_range_next (this=0x7fff2cd32480) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/handler.cc:7612
#5 0x0000000000f6f710 in handler::multi_range_read_next (this=0x7fff2cd32480, range_info=0x7ffff0359910)
at /root/mysql5.7.14/percona-server-5.7.14-7/sql/handler.cc:6614
#6 0x0000000000f706b7 in DsMrr_impl::dsmrr_next (this=0x7fff2cd328f0, range_info=0x7ffff0359910) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/handler.cc:7019
#7 0x00000000019c6210 in ha_innobase::multi_range_read_next (this=0x7fff2cd32480, range_info=0x7ffff0359910)
at /root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/handler/ha_innodb.cc:21372
#8 0x00000000017904b2 in QUICK_RANGE_SELECT::get_next (this=0x7fff2ccc9760) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/opt_range.cc:11171
#9 0x00000000014c5f56 in rr_quick (info=0x7fff2cddf050) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/records.cc:398
#10 0x000000000155c397 in sub_select (join=0x7fff2cdde4e0, qep_tab=0x7fff2cddf000, end_of_records=false)
at /root/mysql5.7.14/
percona-server-5.7.14-7/sql/sql_executor.cc:1274
#11 0x000000000155bd06 in do_select (join=0x7fff2cdde4e0) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:944
#12 0x0000000001559bdc in JOIN::exec (this=0x7fff2cdde4e0) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_executor.cc:199
断点:
row_search_mvcc