这篇文章主要介绍“MySQL中Innodb Handler_read_*参数分析”,在日常操作中,相信很多人在MySQL中Innodb Handler_read_*参数分析问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”MySQL中Innodb Handler_read_*参数分析”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!内部表示如下:实际上这些变量都是MySQL层定义出来的,因为MySQL可以包含多个存储引擎。因此这些值如何增加需要在引擎层的接口中自行实现,也就是说各个引擎都有自己的实现,在MySQL层进行汇总,因此这些值不是某个引擎特有的,打个比免费主机域名方如果有Innodb和MyISAM引擎,那么这些值是两个引擎的总和。本文将以Innodb为主要学习对象进行解释。内部表示:ha_read_key_countInnodb更改接口:ha_innobas免费主机域名e::index_read文档解释:The number of requests to read a row based on a key. If this value is high, it is a good indication that your tables are properly indexed for your queries.源码函数解释:Positions an index cursor to the index specified in the handle. Fetches the row if any.作者解释:这个函数是访问索引的时候定位到值所在的位置用到的函数,因为必须要知道读取索引的开始位置才能向下访问。内部表示:ha_read_next_countInnodb更改接口:ha_innobase::index_next_same ha_innobase::index_next文档解释:The number of requests to read the next row in key order. This value is incremented if you are
querying an index column with a range constraint or if you are doing an index scan.源码函数解释:
index_next – Reads the next row from a cursor, which must have previously been positioned using index_read.
index_next_same – Reads the next row matching to the key value given as the parameter.作者解释:访问索引的下一条数据封装的ha_innobase::general_fetch函数,index_next_same和index_next不同在于访问的方式不一样,比如范围range查询需要用到和索引全扫描也会用到index_next,而ref访问方式会使用index_next_same内部表示:ha_read_first_countInnodb更改接口:ha_innobase::index_first文档解释:The number of times the first entry in an index was read. If this value is high, it suggests that the
server is doing a lot of full index scans; for example, SELECT col1 FROM foo, assuming that col1
is indexed源码函数解释:Positions a cursor on the first record in an index and reads the corresponding row to buf.作者解释:定位索引的第一条数据,实际上也是封装的ha_innobase::index_read函数(如全表扫描/全索引扫描调用)内部表示:ha_read_rnd_next_countInnodb更改接口:ha_innobase::rnd_next文档解释:The number of requests to read the next row in the data file. This value is high if you are doing a lot of table scans. Generally this suggests that your tables are not properly indexed or that your queries
are not written to take advantage of the indexes you have.源码函数解释:Reads the next row in a table scan (also used to read the FIRST row in a table scan).作者解释:全表扫描访问下一条数据,实际上也是封装的ha_innobase::general_fetch,在访问之前会调用ha_innobase::index_first内部表示:ha_read_rnd_countInnodb更改接口:ha_innobase::rnd_posMemory更改接口:ha_heap::rnd_pos文档解释:The number of requests to read a row based on a fixed position. This value is high if you are doing a lot of queries that require sorting of the result. You probably have a lot of queries that require MySQL to scan entire tables or you have joins that do not use keys properly.作者解释:这个状态值在我测试期间只发现对临时表做排序的时候会用到,而且是Memory引擎的,具体只能按照文档理解了。最后2个简单说一下Handler_read_prev
Innodb接口为 ha_innobase::index_prev 访问索引的上一条数据,实际上也是封装的ha_innobase::general_fetch函数,用于ORDER BY DESC 索引扫描避免排序,内部状态值ha_read_prev_count增加。Handler_read_last
Innodb接口为ha_innobase::index_last 访问索引的最后一条数据作为定位,实际上也是封装的ha_innobase::index_read函数,用于ORDER BY DESC 索引扫描避免排序,内部状态值ha_read_last_count增加。Handler_read_first增加1次用于初次定位,Handler_read_key增加1次,Handler_read_rnd_next增加扫描行数。我们前面说过因为ha_innobase::index_first也是封装的ha_innobase::index_read因此都需要+1。Handler_read_first增加1次用于初次定位,Handler_read_key增加1次,Handler_read_next增加扫描行数用于连续访问接下来的行。我们前面说过因为ha_innobase::index_first也是封装的ha_innobase::index_read因此都需要+1。我这里因为是测试索引全是等于10的加上了force indexHandler_read_key增加1次这是用于初次定位,Handler_read_next增加扫描行数次数用于接下来的数据访问。Handler_read_key增加1次这是用于初次定位,Handler_read_next增加扫描行数次数用于接下来的数据访问。Handler_read_first 增加一次作为驱动表z1全表扫描定位的开始,接下来Handler_read_rnd_next扫描全部记录,每次扫描一次在z10表通过索引a_idx定位一次Handler_read_key增加1次,然后接下来进行索引a_idx进行数据查找Handler_read_next增加为扫描的行数。不用过多解释,可以看到Handler_read_last 和Handler_read_prev的用途。到此,关于“MySQL中Innodb Handler_read_*参数分析”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注云技术网站,小编会继续努力为大家带来更多实用的文章!
相关推荐: RedHat 7.7平台安装19RAC静默详细操作过程是什么
本篇内容介绍了“RedHat 7.7平台安装19RAC静默详细操作过程是什么”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!项目RAC节点一RAC节点二主机名or…