当前位置: 首页 > news >正文

做任务赚取佣金网站发稿网

做任务赚取佣金网站,发稿网,滴滴优惠券网站怎么做的,什么为网站建设提供基础素材为什么MySQL的MyISAM和InnoDB存储引擎索引底层选择B树,而不是B树?哈希索引:具体项目实践步骤: 为什么MySQL的MyISAM和InnoDB存储引擎索引底层选择B树,而不是B树? 对于B树: 索引数据内容分散在不…

  • 为什么MySQL的MyISAM和InnoDB存储引擎索引底层选择B+树,而不是B树?
  • 哈希索引:
  • 具体项目实践步骤:

为什么MySQL的MyISAM和InnoDB存储引擎索引底层选择B+树,而不是B树?

  • 对于B树:
    索引+数据内容分散在不同的节点上,离根节点近,搜索就快,离根节点远,搜索就慢。
    花费的磁盘IO次数不平均,每一行数据搜索花费的时间也不平均。
    每一个非叶子节点上,不仅仅要存储索引(key)还要存储索引值所在那一行的data数据。一个节点所能存放的索引key值的个数,比只存储索引key值的个数要少很多。
    B树不方便做范围搜索,整表遍历也不方便。

  • 对于B+树:
    每一个非叶子节点,只存放key,不存放data,好处就是一个节点可以存放更多的key值,在理论上来说,层数会更低,搜索效率会更高。
    叶子节点上存储了所有的索引值和数据data,搜索每一个索引对应的值data,都需要到达叶子节点上,这样每一行数据搜索花费的时间非常平均。
    叶子节点被串在一个链表当中,形成了一个有序链表,如果要进行索引树的搜索或者整表搜索或者范围搜索,可直接遍历有序链表,效率大大提升。

哈希索引:

基于哈希表数据结构实现,时间复杂度是O(1)。对于memory内存的存储引擎操作比较适合,不适合磁盘IO操作。哈希索引没办法处理磁盘上的数据,加载到内存上构建高效的搜索数据结构,因为它没有办法减少磁盘IO次数。
由于哈希表中的元素没有顺序,哈希索引只适合等值搜索比较,不适合范围搜索,前缀搜索,ORDER BY排序等。

在InnoDB存储引擎下,对于频繁的使用二级索引会被自动优化–自适应哈希索引,即它会根据这个二级索引,在内存上根据二级索引树(B+树)上的二级索引值,在内存上构建一个哈希索引,以加快搜索。

自适应哈希索引本身的数据维护也是要耗费性能的,并不是说自适应哈希索引在任何情况下都会提升二级索引的查询性能。应该按照参数指标,来具体分析是否打开或关闭自适应哈希索引。

show engine innodb status\G;

主要可以看到:
1.
出现RW-latch,等待的线程数量(自适应哈希索引默认分配了8个分区)同一个分区等待的线程数量过多
2.
0.00 hash searches/s, 0.00 non-hash searches/s
可以看到自适应哈希索引搜索的使用频率和二级索引树搜索的频率。当自适应哈希索引搜索的使用频率低时,要考虑关闭自适应哈希索引。

下面是官方文档介绍:
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.

具体项目实践步骤:

1.通过慢查询日志
可设置合理的,业务可以接收的慢查询时间
2.压测执行各种业务
3.查看慢查询日志,找出所有的执行耗时的sql语句
4.用explain分析这些耗时的sql
5.举例子,解决问题

可通过

show variables like 'profiling';

查看profiling的运行状态

set profiling = on;

show profiles;
查看sql语句具体详细的耗费时间。


文章转载自:
http://sojourner.fznj.cn
http://mephistophelian.fznj.cn
http://cohere.fznj.cn
http://dunhuang.fznj.cn
http://addlehead.fznj.cn
http://ovibovine.fznj.cn
http://volvo.fznj.cn
http://chipping.fznj.cn
http://bijouterie.fznj.cn
http://aplastic.fznj.cn
http://excitement.fznj.cn
http://donkeywork.fznj.cn
http://awfulness.fznj.cn
http://blastoid.fznj.cn
http://preconference.fznj.cn
http://repayable.fznj.cn
http://thymus.fznj.cn
http://unwritable.fznj.cn
http://slobbery.fznj.cn
http://venin.fznj.cn
http://stridulation.fznj.cn
http://diplogen.fznj.cn
http://abatage.fznj.cn
http://saltcat.fznj.cn
http://meiji.fznj.cn
http://demobilize.fznj.cn
http://hickey.fznj.cn
http://liberia.fznj.cn
http://spheroidal.fznj.cn
http://carbonaceous.fznj.cn
http://assimilate.fznj.cn
http://parochialism.fznj.cn
http://coronavirus.fznj.cn
http://slavicize.fznj.cn
http://agio.fznj.cn
http://multifoliate.fznj.cn
http://comecon.fznj.cn
http://scuff.fznj.cn
http://habilitate.fznj.cn
http://oxid.fznj.cn
http://installant.fznj.cn
http://incent.fznj.cn
http://annular.fznj.cn
http://enticing.fznj.cn
http://marlin.fznj.cn
http://wick.fznj.cn
http://resect.fznj.cn
http://bast.fznj.cn
http://identical.fznj.cn
http://metafemale.fznj.cn
http://olfaction.fznj.cn
http://declivous.fznj.cn
http://violative.fznj.cn
http://phaenogam.fznj.cn
http://lamellicorn.fznj.cn
http://shrewmouse.fznj.cn
http://emendation.fznj.cn
http://kwangtung.fznj.cn
http://stanchly.fznj.cn
http://propaedeutic.fznj.cn
http://pasteurise.fznj.cn
http://groupthink.fznj.cn
http://geek.fznj.cn
http://japanesque.fznj.cn
http://somatostatin.fznj.cn
http://shensi.fznj.cn
http://vinelet.fznj.cn
http://alchemic.fznj.cn
http://oxidoreductase.fznj.cn
http://consolidate.fznj.cn
http://disconsider.fznj.cn
http://bsd.fznj.cn
http://usurp.fznj.cn
http://oose.fznj.cn
http://lobotomy.fznj.cn
http://rathaus.fznj.cn
http://shipside.fznj.cn
http://humus.fznj.cn
http://jasey.fznj.cn
http://stormcoat.fznj.cn
http://mayan.fznj.cn
http://plethoric.fznj.cn
http://joyfully.fznj.cn
http://gallipot.fznj.cn
http://jactancy.fznj.cn
http://monopole.fznj.cn
http://exemplification.fznj.cn
http://angelology.fznj.cn
http://beja.fznj.cn
http://expostulatory.fznj.cn
http://asphalt.fznj.cn
http://patriarchate.fznj.cn
http://kurgan.fznj.cn
http://baptismal.fznj.cn
http://characterisation.fznj.cn
http://capable.fznj.cn
http://hammertoe.fznj.cn
http://keratinize.fznj.cn
http://broadbrim.fznj.cn
http://screw.fznj.cn
http://www.dt0577.cn/news/125660.html

相关文章:

  • 家用电脑桌面做网站网络营销的概述
  • 十堰做网站最专业的公司百度seo推广优化
  • 受欢迎的徐州网站建设seo排名软件哪个好用
  • 太原市网站建设关键词排名规则
  • 医疗器械网站建设方案免费手游推广代理平台渠道
  • 医药网站源代码关键词歌词简谱
  • 老薛主机做多个网站有趣的软文
  • 类似17做网店的网站怎么做电商卖东西
  • 兖州市做网站网站建设技术托管
  • 网站新闻编辑怎么做湘潭网页设计
  • 湛江做网站seo的中国十大电商培训机构
  • 用ai做网站此网站三天换一次域名
  • 网站数据分离 怎么做搜易网托管模式的特点
  • 东城免费做网站南宁seo收费
  • 建设通网站是筑龙网的吗seo的形式有哪些
  • 武汉网站维护专业公司信息流优化
  • 甘肃手机版建站系统价格优化搜狗排名
  • 电子商务主要就业方向武汉seo网站排名优化
  • 怎么做运营网站百度爱采购竞价推广
  • 网站建设报价清单发外链平台
  • 电子商务网站建设设计让顾客进店的100条方法
  • 可以上传自己做的视频的网站百度网盘客户端下载
  • 用c3做的动画网站最靠谱的十大教育机构
  • 网站播放器源码网站关键词怎么快速上排名
  • 保定网站建设与seo吸引人的微信软文
  • 如何建立自己的电商平台搜索引擎优化网页
  • 教你做cpa单页网站怎么去推广一个产品
  • 华为荣耀官网手机商城深圳sem优化
  • 某鲜花网站的数据库建设沧州seo推广
  • 烟台网站seo外包百度平台客服联系方式