ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

MySQL 5.7 下的 hint

2020-07-08 22:42:06  阅读:433  来源: 互联网

标签:NO Affects 5.7 hint MRR MySQL table block


参考 https://dev.mysql.com/doc/refman/5.7/en/optimizer-hints.html

Hint Name Description Applicable Scopes
BKA, NO_BKA Affects Batched Key Access join processing Query block, table
BNL, NO_BNL Affects Block Nested-Loop join processing Query block, table
MAX_EXECUTION_TIME Limits statement execution time Global
MRR, NO_MRR Affects Multi-Range Read optimization Table, index
NO_ICP Affects Index Condition Pushdown optimization Table, index
NO_RANGE_OPTIMIZATION Affects range optimization Table, index
QB_NAME Assigns name to query block Query block
SEMIJOIN, NO_SEMIJOIN Affects semijoin strategies Query block
SUBQUERY Affects materialization, IN-to-EXISTS subquery stratgies Query block

表级hint,

  • BKA, NO_BKA: Enable or disable BKA for the specified tables.
  • BNL, NO_BNL: Enable or disable BNL for the specified tables.

索引级别的hint

  • MRR, NO_MRR: Enable or disable MRR for the specified table or indexes. MRR hints apply only to InnoDB and MyISAM tables.
  • NO_ICP: Disable ICP for the specified table or indexes. By default, ICP is a candidate optimization strategy, so there is no hint for enabling it.
  • NO_RANGE_OPTIMIZATION: Disable index range access for the specified table or indexes. This hint also disables Index Merge and Loose Index Scan for the table or indexes. By default, range access is a candidate optimization strategy, so there is no hint for enabling it.

子查询的hint

  • SEMIJOIN, NO_SEMIJOIN: Enable or disable the named semijoin strategies.

控制SQL执行时间的hint

  • MAX_EXECUTION_TIME(N)

还有个QB_NAME(name)没搞明白。。。

测试了下,好像故意写错了,也没什么影响

mysql> explain select /*+ BNA(fuck_wisedu)*/ a.clusterid,a.ip,a.bak_date,a.start_time,a.end_time,state  from mysql_backup_job a  left join mysql_conf b on a.ip=b.ip  where bak_date = '2020-07-08'  and b.group_id='23333'    and  state = 'OK' ;
+----+-------------+-------+------------+------+-------------------------------------------------------+-------------------------------+---------+----------------+-------+----------+------------------------------------+
| id | select_type | table | partitions | type | possible_keys                                         | key                           | key_len | ref            | rows  | filtered | Extra                              |
+----+-------------+-------+------------+------+-------------------------------------------------------+-------------------------------+---------+----------------+-------+----------+------------------------------------+
|  1 | SIMPLE      | a     | NULL       | ref  | ip_idx,date_idx                                       | date_idx                      | 3       | const          | 15574 |    10.00 | Using where                        |
|  1 | SIMPLE      | b     | NULL       | ref  | IDX_IP                                                | IDX_IP                        | 47      | mysql_bak.a.ip |     1 |    10.00 | Using index condition; Using where |
+----+-------------+-------+------------+------+-------------------------------------------------------+-------------------------------+---------+----------------+-------+----------+------------------------------------+
2 rows in set, 1 warning (0.00 sec)

标签:NO,Affects,5.7,hint,MRR,MySQL,table,block
来源: https://www.cnblogs.com/Coye/p/13269666.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有