質問編集履歴
1
回答で教授いただいた`EXPLAIN`の実行結果を追記。
title
CHANGED
File without changes
|
body
CHANGED
@@ -98,4 +98,37 @@
|
|
98
98
|
| 森 | 090-2984-XXXX | 東京都 | 男 | 45 |
|
99
99
|
+--------+---------------+-----------+-----+-----+
|
100
100
|
2 rows in set (0.00 sec)
|
101
|
+
```
|
102
|
+
|
103
|
+
---
|
104
|
+
##(追記)
|
105
|
+
|
106
|
+
###先頭文字マッチの`EXPLAIN`の実行結果
|
107
|
+
|
108
|
+
```MySQL
|
109
|
+
mysql> EXPLAIN SELECT * FROM Address WHERE phone_nbr LIKE "090%";
|
110
|
+
+----+-------------+---------+------------+------+---------------+------+---------+------+------+----------+-------------+
|
111
|
+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
|
112
|
+
+----+-------------+---------+------------+------+---------------+------+---------+------+------+----------+-------------+
|
113
|
+
| 1 | SIMPLE | Address | NULL | ALL | NULL | NULL | NULL | NULL | 9 | 11.11 | Using where |
|
114
|
+
+----+-------------+---------+------------+------+---------------+------+---------+------+------+----------+-------------+
|
115
|
+
1 row in set, 1 warning (0.00 sec)
|
116
|
+
|
117
|
+
mysql> EXPLAIN SELECT * FROM Address WHERE phone_nbr REGEXP "^090";
|
118
|
+
+----+-------------+---------+------------+------+---------------+------+---------+------+------+----------+-------------+
|
119
|
+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
|
120
|
+
+----+-------------+---------+------------+------+---------------+------+---------+------+------+----------+-------------+
|
121
|
+
| 1 | SIMPLE | Address | NULL | ALL | NULL | NULL | NULL | NULL | 9 | 100.00 | Using where |
|
122
|
+
+----+-------------+---------+------------+------+---------------+------+---------+------+------+----------+-------------+
|
123
|
+
1 row in set, 1 warning (0.00 sec)
|
124
|
+
```
|
125
|
+
|
126
|
+
###ついでのSHOW INDEX
|
127
|
+
```MySQL
|
128
|
+
mysql> SHOW INDEX FROM Address;
|
129
|
+
+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
|
130
|
+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
|
131
|
+
+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
|
132
|
+
| address | 0 | PRIMARY | 1 | name | A | 9 | NULL | NULL | | BTREE | | |
|
133
|
+
+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
|
101
134
|
```
|