日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql源码自适应哈希索引_MySQL 自适应哈希索引

發布時間:2023/12/20 数据库 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql源码自适应哈希索引_MySQL 自适应哈希索引 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、介紹

哈希(hash)是一種非常快的查找方法,一般情況下查找的時間復雜度為O(1)。常用于連接(join)操作,如Oracle中的哈希連接(hash join)。

InnoDB存儲引擎會監控對表上索引的查找,如果觀察到建立哈希索引可以帶來速度的提升,則建立哈希索引,所以稱之為自適應(adaptive)的。

自適應哈希索引通過緩沖池的B+樹構造而來,因此建立的速度很快。而且不需要將整個表都建哈希索引,InnoDB存儲引擎會自動根據訪問的頻率和模式來為某些頁建立哈希索引。

自適應哈希索引經哈希函數映射到一個哈希表中,因此對字典類型的查詢非常快,但是對于范圍查找就無能為力了。

二、示例

三、限制

1.只能用于等值比較,例如=, <=>,in

2.無法用于排序

3.有沖突可能

4.Mysql自動管理,人為無法干預。

四、通過SHOW ENGINE INNODB STATUS 查看自適應哈希索引的使用情況

In MySQL 5.7, the adaptive hash index search system is partitioned. Each index is bound to a specific partition, and each partition is protected by a separate latch.

Partitioning is controlled by the?innodb_adaptive_hash_index_parts?configuration option. In earlier releases, the adaptive hash index search system was

protected by a single latch which could become a point of contention under heavy workloads. The?innodb_adaptive_hash_index_parts?option is set to 8 by default.

The maximum setting is 512.

The hash index is always built based on an existing?B-tree?index on the table.?InnoDB?can build a hash index on a prefix of any length of the key defined for the B-tree,

depending on the pattern of searches that?InnoDB?observes for the B-tree index. A hash index can be partial, covering only those pages of the index that are often accessed.

You can monitor the use of the adaptive hash index and the contention for its use in the?SEMAPHORES?section of the output of the?SHOW ENGINE INNODB STATUS

command. If you see many threads waiting on an RW-latch created in?btr0sea.c, then it might be useful to disable adaptive hash indexing.

-------------------------------------

INSERT BUFFER AND ADAPTIVE HASH INDEX

-------------------------------------

Ibuf: size 1, free list len 0, seg size 2, 94 merges

merged operations:

insert 280, delete mark 0, delete 0

discarded operations:

insert 0, delete mark 0, delete 0

Hash table size 4425293, node heap has 1337 buffer(s)

174.24 hash searches/s, 169.49 non-hash searches/s

哈希索引只能用來搜索等值的查詢,對于其他查找類型,如范圍查找,是不能使用哈希索引的,因此這里出現no--hash searches的情況。

通過hash searches:non-hash searches可以大概了解使用哈希索引后的效率

轉載自:

https://www.cnblogs.com/yuyutianxia/p/3841657.html

總結

以上是生活随笔為你收集整理的mysql源码自适应哈希索引_MySQL 自适应哈希索引的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。