Skip to content

Instantly share code, notes, and snippets.

@kamipo
Last active August 22, 2017 12:53
Show Gist options
  • Save kamipo/5abfa1f5bdbdcdde78d867106b8cdeb7 to your computer and use it in GitHub Desktop.
Save kamipo/5abfa1f5bdbdcdde78d867106b8cdeb7 to your computer and use it in GitHub Desktop.
root@localhost [test] > create table t (a int, b int, c varchar(255), index (a, b));
Query OK, 0 rows affected (0.03 sec)
root@localhost [test] > insert into t values
-> (200, 200, 'aaa'),
-> (199, 199, 'aaa'),
-> (198, 198, 'aaa'),
-> (197, 197, 'aaa'),
-> (196, 196, 'aaa'),
-> (195, 195, 'aaa'),
-> (194, 194, 'aaa'),
-> (193, 193, 'aaa'),
-> (192, 192, 'aaa'),
-> (191, 191, 'aaa'),
-> (190, 190, 'aaa'),
-> (189, 189, 'aaa'),
-> (188, 188, 'aaa'),
-> (187, 187, 'aaa'),
-> (186, 186, 'aaa'),
-> (185, 185, 'aaa'),
-> (184, 184, 'aaa'),
-> (183, 183, 'aaa'),
-> (182, 182, 'aaa'),
-> (181, 181, 'aaa'),
-> (180, 180, 'aaa'),
-> (179, 179, 'aaa'),
-> (178, 178, 'aaa'),
-> (177, 177, 'aaa'),
-> (176, 176, 'aaa'),
-> (175, 175, 'aaa'),
-> (174, 174, 'aaa'),
-> (173, 173, 'aaa'),
-> (172, 172, 'aaa'),
-> (171, 171, 'aaa'),
-> (170, 170, 'aaa');
Query OK, 31 rows affected (0.00 sec)
Records: 31 Duplicates: 0 Warnings: 0
root@localhost [test] > select a, b from t;
+------+------+
| a | b |
+------+------+
| 170 | 170 |
| 171 | 171 |
| 172 | 172 |
| 173 | 173 |
| 174 | 174 |
| 175 | 175 |
| 176 | 176 |
| 177 | 177 |
| 178 | 178 |
| 179 | 179 |
| 180 | 180 |
| 181 | 181 |
| 182 | 182 |
| 183 | 183 |
| 184 | 184 |
| 185 | 185 |
| 186 | 186 |
| 187 | 187 |
| 188 | 188 |
| 189 | 189 |
| 190 | 190 |
| 191 | 191 |
| 192 | 192 |
| 193 | 193 |
| 194 | 194 |
| 195 | 195 |
| 196 | 196 |
| 197 | 197 |
| 198 | 198 |
| 199 | 199 |
| 200 | 200 |
+------+------+
31 rows in set (0.00 sec)
root@localhost [test] > explain select a, b from t;
+----+-------------+-------+------------+-------+---------------+------+---------+------+------+----------+-------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-------+------------+-------+---------------+------+---------+------+------+----------+-------------+
| 1 | SIMPLE | t | NULL | index | NULL | a | 10 | NULL | 31 | 100.00 | Using index |
+----+-------------+-------+------------+-------+---------------+------+---------+------+------+----------+-------------+
1 row in set, 1 warning (0.00 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment