91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

MySQL5.7查詢性能改進

發布時間:2020-07-01 06:43:40 來源:網絡 閱讀:554 作者:蘇黎世1995 欄目:MySQL數據庫

1.子查詢

1.1 MySQL5.5
mysql> explain extended select id,k,c,pad from sbtest1 where id in (select id from sbtest1 where k in ('50385','50011','43490','504922'));
+----+--------------------+---------+-----------------+---------------+---------+---------+------+--------+----------+-------------+
| id | select_type        | table   | type            | possible_keys | key     | key_len | ref  | rows   | filtered | Extra       |
+----+--------------------+---------+-----------------+---------------+---------+---------+------+--------+----------+-------------+
|  1 | PRIMARY            | sbtest1 | ALL             | NULL          | NULL    | NULL    | NULL | 612555 |   100.00 | Using where |
|  2 | DEPENDENT SUBQUERY | sbtest1 | unique_subquery | PRIMARY,k_1   | PRIMARY | 4       | func |      1 |   100.00 | Using where |
+----+--------------------+---------+-----------------+---------------+---------+---------+------+--------+----------+-------------+
2 rows in set, 1 warning (0.00 sec)
1.2 MySQL5.7
mysql> explain select id,k,c,pad from sbtest1 where id in (select id from sbtest1 where k in ('50385','50011','43490','50492'));
+----+-------------+---------+------------+--------+---------------+---------+---------+-------------------+------+----------+--------------------------+
| id | select_type | table   | partitions | type   | possible_keys | key     | key_len | ref               | rows | filtered | Extra                    |
+----+-------------+---------+------------+--------+---------------+---------+---------+-------------------+------+----------+--------------------------+
|  1 | SIMPLE      | sbtest1 | NULL       | range  | PRIMARY,k_1   | k_1     | 4       | NULL              |  253 |   100.00 | Using where; Using index |
|  1 | SIMPLE      | sbtest1 | NULL       | eq_ref | PRIMARY       | PRIMARY | 4       | sbtest.sbtest1.id |    1 |   100.00 | NULL                     |
+----+-------------+---------+------------+--------+---------------+---------+---------+-------------------+------+----------+--------------------------+
2 rows in set, 1 warning (0.00 sec)

2.union all

2.1 MySQL5.5,會將結果存在臨時表中
mysql> explain (select k from sbtest1 order by k) union all (select k from sbtest2 order by k);
+----+--------------+------------+-------+---------------+------+---------+------+--------+-------------+
| id | select_type  | table      | type  | possible_keys | key  | key_len | ref  | rows   | Extra       |
+----+--------------+------------+-------+---------------+------+---------+------+--------+-------------+
|  1 | PRIMARY      | sbtest1    | index | NULL          | k_1  | 4       | NULL | 612555 | Using index |
|  2 | UNION        | sbtest2    | index | NULL          | k_2  | 4       | NULL | 615365 | Using index |
| NULL | UNION RESULT | <union1,2> | ALL   | NULL          | NULL | NULL    | NULL |   NULL |             |
+----+--------------+------------+-------+---------------+------+---------+------+--------+-------------+
3 rows in set (0.00 sec)
2.2 MySQL5.7,直接展示結果
mysql> explain (select k from sbtest1 order by k) union all (select k from sbtest2 order by k);
+----+-------------+---------+------------+-------+---------------+------+---------+------+--------+----------+-------------+
| id | select_type | table   | partitions | type  | possible_keys | key  | key_len | ref  | rows   | filtered | Extra       |
+----+-------------+---------+------------+-------+---------------+------+---------+------+--------+----------+-------------+
|  1 | PRIMARY     | sbtest1 | NULL       | index | NULL          | k_1  | 4       | NULL | 597600 |   100.00 | Using index |
|  2 | UNION       | sbtest2 | NULL       | index | NULL          | k_2  | 4       | NULL | 597744 |   100.00 | Using index |
+----+-------------+---------+------------+-------+---------------+------+---------+------+--------+----------+-------------+
2 rows in set, 1 warning (0.00 sec)

3 in查詢

3.1 MySQL5.5
mysql> explain select * from sbtest1 where (k,pad) in ((43490,'24909597713-10795827686-60824686337-78820064088-50914299985'),(50088,'56702105543-74313438035-88959810983-96828764563-29757615888'));
+----+-------------+---------+------+---------------+------+---------+------+--------+-------------+
| id | select_type | table   | type | possible_keys | key  | key_len | ref  | rows   | Extra       |
+----+-------------+---------+------+---------------+------+---------+------+--------+-------------+
|  1 | SIMPLE      | sbtest1 | ALL  | NULL          | NULL | NULL    | NULL | 612555 | Using where |
+----+-------------+---------+------+---------------+------+---------+------+--------+-------------+
1 row in set (0.00 sec)
3.2 MySQL5.7
mysql> explain select * from sbtest1 where (k,pad) in ((43490,'24909597713-10795827686-60824686337-78820064088-50914299985'),(50088,'56702105543-74313438035-88959810983-96828764563-29757615888'));
+----+-------------+---------+------------+-------+---------------+------+---------+------+------+----------+-------------+
| id | select_type | table   | partitions | type  | possible_keys | key  | key_len | ref  | rows | filtered | Extra       |
+----+-------------+---------+------------+-------+---------------+------+---------+------+------+----------+-------------+
|  1 | SIMPLE      | sbtest1 | NULL       | range | k_1           | k_1  | 4       | NULL |   77 |    20.00 | Using where |
+----+-------------+---------+------------+-------+---------------+------+---------+------+------+----------+-------------+
1 row in set, 1 warning (0.00 sec)
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

琼海市| 宿州市| 邵东县| 大英县| 海兴县| 凤山市| 葵青区| 互助| 浮梁县| 德庆县| 罗平县| 余庆县| 丰城市| 台南县| 忻城县| 台安县| 澎湖县| 崇明县| 特克斯县| 上思县| 五原县| 冷水江市| 五寨县| 美姑县| 洞头县| 高安市| 文安县| 永清县| 延长县| 绥德县| 彭山县| 沭阳县| 上虞市| 邮箱| 额济纳旗| 崇礼县| 双江| 小金县| 郧西县| 双鸭山市| 晋城|