25. ? Copyrights 2001~2016, EXEM CO.,LTD. All Rights Reserved.
Hint ???
?? ??? ?? ??
? ???? ??? ??? ?
??? ??
(http://dev.mysql.com/d
oc/refman/5.7/en/keywo
rds.html)
USE INDEX ??? ???? ??
USE {INDEX|KEY} [FOR {JOIN|ORDER BY|GR
OUP BY}] ([index_list])
INGONRE INDEX ??? ???? ???? ??
IGNORE {INDEX|KEY} [FOR {JOIN|ORDER BY|
GROUP BY}] (index_list)
FORCE INDEX ??? ???? ??? ??
FORCE {INDEX|KEY} [FOR {JOIN|ORDER BY|
GROUP BY}] (index_list)
STRAIGHT_JOIN ??? ??? FROM?? ??? ?? SELECT STRAIGHT_JOIN ... FROM
SQL_SMALL_RESULT ?????? ??? '??' ???? ??? SELECT SQL_SMALL_RESULT ... FROM
SQL_BIG_RESULT ?????? ??? '?' ???? ??? SELECT SQL_BIG_RESULT ... FROM
SQL_BUFFER_RESULT ??? ?????? ??, ?????? ???? SELECT SQL_BUFFER_RESULT ... FROM
SQL_CACHE ??? ????(query_cache_type=2)? ??? SELECT SQL_CACHE ... FROM
SQL_NO_CACHE ??? ????? ???? ?? SELECT SQL_NO_CACHE ... FROM
SQL_CALC_FOUND_ROWS
LIMIT? ?? ??? ?? ???? ????,
FOUND_ROWS()??? ????.
SELECT SQL_CALC_FOUND_ROWS ... FROM
HIGH_PRIORITY ????? ????(ex. Myisam)???? ???? ??,
?? ??? ??? ??? ? ?? ???? ?????
??,
SELECT HIFH_PRIORITY ... FROM
LOW_PRIORITY SELECT LOW_PRIORITY ... FROM
DELAYED INSERT, REPLACE??? ??? ???? ??? ?? INSERT DELAYED INTO ...
26. ? Copyrights 2001~2016, EXEM CO.,LTD. All Rights Reserved.
Hint ???
ignore index(key|index) ?? ??
mysql> explain select * from employees.employees where emp_no<30000
+----+-------------+-----------+------------+-------+---------------+---------+---------+------+-------+----------+-------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-----------+------------+-------+---------------+---------+---------+------+-------+----------+-------------+
| 1 | SIMPLE | employees | NULL | range | PRIMARY | PRIMARY | 4 | NULL | 39392 | 100.00 | Using where |
+----+-------------+-----------+------------+-------+---------------+---------+---------+------+-------+----------+-------------+
mysql> explain select * from employees.employees ignore index(primary) where emp_no<30000;
+----+-------------+-----------+------------+------+---------------+------+---------+------+--------+----------+-------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-----------+------------+------+---------------+------+---------+------+--------+----------+-------------+
| 1 | SIMPLE | employees | NULL | ALL | NULL | NULL | NULL | NULL| 299113 | 33.33 | Using where |
+----+-------------+-----------+------------+------+---------------+------+---------+------+--------+----------+-------------+
27. ? Copyrights 2001~2016, EXEM CO.,LTD. All Rights Reserved.
Hint ???
straight join ?? ??
mysql> explain select * from employees,departments limit 1;
+----+-------------+-------------+------------+-------+---------------+-----------+---------+------+--------+----------+---------------------------------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-------------+------------+-------+---------------+-----------+---------+------+--------+----------+---------------------------------------+
| 1 | SIMPLE | departments | NULL | index | NULL | dept_name | 122 | NULL | 9 | 100.00 | Using index |
| 1 | SIMPLE | employees | NULL | ALL | NULL | NULL | NULL | NULL | 299113 | 100.00 | Using join buffer (Block Nested Loop) |
+----+-------------+-------------+------------+-------+---------------+-----------+---------+------+--------+----------+---------------------------------------+
2 rows in set, 1 warning (0.00 sec)
mysql> explain select STRAIGHT_JOIN * from employees,departments limit 1;
+----+-------------+-------------+------------+-------+---------------+-----------+---------+------+--------+----------+----------------------------------------------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-------------+------------+-------+---------------+-----------+---------+------+--------+----------+----------------------------------------------------+
| 1 | SIMPLE | employees | NULL | ALL | NULL | NULL | NULL | NULL | 299113 | 100.00 | NULL |
| 1 | SIMPLE | departments | NULL | index | NULL | dept_name | 122 | NULL | 9 | 100.00 | Using index; Using join buffer (Block Nested Loop) |
+----+-------------+-------------+------------+-------+---------------+-----------+---------+------+--------+----------+----------------------------------------------------+
2 rows in set, 1 warning (.00 sec)
28. ? Copyrights 2001~2016, EXEM CO.,LTD. All Rights Reserved.
Hint ???
SQL_CACHE ?? ??
mysql> select * from employees.employees limit 100000;
mysql> show status like 'Qcache_inserts';
+----------------+-------+
| Variable_name | Value |
+----------------+-------+
| Qcache_inserts | 3 |
+----------------+-------+
mysql> select sql_cache * from employees.employees limit 100000;
mysql> show status like 'Qcache_inserts';
+----------------+-------+
| Variable_name | Value |
+----------------+-------+
| Qcache_inserts | 4 |
+----------------+-------+