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

网站建设有哪些步骤新手怎样推销自己的产品

网站建设有哪些步骤,新手怎样推销自己的产品,公司网站的设计风格大多是,服务器安全加固方案统计一张表的总数量,是我们开发中常有的业务需求,通常情况下,我们都是使用 select count(*) from table SQL 语句来完成。随着业务数据的增加,你会发现这条语句执行的速度越来越慢,为什么它会变慢呢? 为什…

统计一张表的总数量,是我们开发中常有的业务需求,通常情况下,我们都是使用 select count(*) from table SQL 语句来完成。随着业务数据的增加,你会发现这条语句执行的速度越来越慢,为什么它会变慢呢?

为什么会变慢?想要得到答案就需要知道 MySQL 是如何统计总数量的,先说一个前提吧,count(*) 的具体实现是由存储引擎实现的,也就是说不同的存储引擎实现的方式不一样。标题:为什么select count( * ) from table,在 InnoDB 引擎中比 MyISAM 慢?也是高频面试题。

InnoDB和MyISAM 是我们常用的 MySQL 存储引擎,所以主要对比一下 count(*) 在 InnoDB 和 MyISAM 中的实现:

  • 「在 MyISAM 存储引擎中,把表的总行数存储在磁盘上,当执行 select count(*) from table 时,直接返回总数据」。
  • 「在 InnoDB 存储引擎中,跟 MyISAM 不一样,没有将总行数存储在磁盘上,当执行 select count(*) from table 时,会先把数据读出来,一行一行的累加,最后返回总数量」。

知道了 InnoDB 和 MyISAM 引擎 count(*) 实现之后,为什么select count(*) from table,在 InnoDB 引擎中比 MyISAM 慢?应该有答案了吧,但是这个结论需要有一个前提,就是统计 SQL 不带过滤条件。如果 统计数量 SQL 语句为:select count(*) from table where x = 23,那么在 MyISAM 中就不一定比 InnoDB 快了。

「InnoDB 中 count(*) 语句是在执行的时候,全表扫描统计总数量,所以当数据越来越大时,语句就越来越耗时了」,为什么 InnoDB 引擎不像 MyISAM 引擎一样,将总行数存储到磁盘上?这跟 InnoDB 的事务特性有关,由于多版本并发控制(MVCC)的原因,InnoDB 表“应该返回多少行”也是不确定的。

不妨用一个例子来说明一下,假设现在 t 表中有 10000 条数据,现在有三个用户同时访问的会话:

  • 会话 A 先启动事务并查询一次表的总行数。
  • 会话 B 启动事务,插入一行后记录后,查询表的总行数。
  • 会话 C 先启动一个单独的语句,插入一行记录后,查询表的总行数。

会话执行流程表

会话A会话B会话C
begin;
select count(*) from table
insert into table (插入一行)
begin;
insert into table(插入一行)
select count(*) from table;(返回10000)select count(*) from table;(返回10002)select count(*) from table;(返回10001)

假设从上到下是按照时间顺序执行的,同一行语句是在同一时刻执行的。可以看出在最后时刻,三个会话返回的总行数不一样。

出现不一样的结果跟 InnoDB 存储引擎有关系,「在默认隔离级别可重复读的情况下,通过多版本并发控制(MVCC)来实现,每一行记录都需要判断自己是否对这个会话可见,因此在统计总数量时,InnoDB 只好把数据一行一行的读取出来判断,只有当前会话可见的才纳入统计中」。所以同一时刻不同会话查询到的数量就不一样。

InnoDB 引擎在 count(*)语句上也做了优化,我们知道,在 InnoDB 存储引擎中是以索引组织表的方式存储数据,主键索引树上叶子节点存放在所有的数据,而普通索引树的叶子节点是主键值,所以普通索引树会比主键索引树小很多,但是数量是一样的,也就是说遍历主键索引树和普通索引树得到的结果都是一样的。MySQL 就利用了这一特性,在 InnoDB 中执行 select count(*) from table 语句时,MySQL 优化器会找到最小的那棵索引树来遍历,这样可能就可以减少加载次数,在一定程度上提升了 count(*)的执行效率。


文章转载自:
http://verism.jtrb.cn
http://gingerbready.jtrb.cn
http://mysticize.jtrb.cn
http://shmutz.jtrb.cn
http://sanguinarily.jtrb.cn
http://sedentariness.jtrb.cn
http://protamin.jtrb.cn
http://teach.jtrb.cn
http://hitchhike.jtrb.cn
http://lustre.jtrb.cn
http://excorticate.jtrb.cn
http://pycnidium.jtrb.cn
http://coraciiform.jtrb.cn
http://octavo.jtrb.cn
http://karroo.jtrb.cn
http://furnisher.jtrb.cn
http://inexhaustive.jtrb.cn
http://semmit.jtrb.cn
http://memorizer.jtrb.cn
http://paroxysmal.jtrb.cn
http://chastity.jtrb.cn
http://benedictional.jtrb.cn
http://freaky.jtrb.cn
http://codicillary.jtrb.cn
http://salyrgan.jtrb.cn
http://anus.jtrb.cn
http://nafta.jtrb.cn
http://autochthon.jtrb.cn
http://honolulan.jtrb.cn
http://slavophobe.jtrb.cn
http://granth.jtrb.cn
http://tentie.jtrb.cn
http://boogeyman.jtrb.cn
http://backslidden.jtrb.cn
http://cheap.jtrb.cn
http://searching.jtrb.cn
http://transplantate.jtrb.cn
http://wattled.jtrb.cn
http://stactometer.jtrb.cn
http://cemically.jtrb.cn
http://overridden.jtrb.cn
http://englobe.jtrb.cn
http://minitype.jtrb.cn
http://rajahship.jtrb.cn
http://trochosphere.jtrb.cn
http://inconsequence.jtrb.cn
http://tesseract.jtrb.cn
http://fluidounce.jtrb.cn
http://horsefly.jtrb.cn
http://underpowered.jtrb.cn
http://bp.jtrb.cn
http://kaury.jtrb.cn
http://ancestor.jtrb.cn
http://conspicuously.jtrb.cn
http://coinsurance.jtrb.cn
http://copyreader.jtrb.cn
http://referring.jtrb.cn
http://cheiromancy.jtrb.cn
http://integrator.jtrb.cn
http://nucha.jtrb.cn
http://rimu.jtrb.cn
http://siffleuse.jtrb.cn
http://multisession.jtrb.cn
http://somatotroph.jtrb.cn
http://judo.jtrb.cn
http://neotene.jtrb.cn
http://repo.jtrb.cn
http://topic.jtrb.cn
http://lassen.jtrb.cn
http://orthocephaly.jtrb.cn
http://babette.jtrb.cn
http://canadian.jtrb.cn
http://monolith.jtrb.cn
http://unemancipated.jtrb.cn
http://pursiness.jtrb.cn
http://urn.jtrb.cn
http://eyewink.jtrb.cn
http://brachypterous.jtrb.cn
http://parastatal.jtrb.cn
http://coherent.jtrb.cn
http://liffey.jtrb.cn
http://epistemology.jtrb.cn
http://issuer.jtrb.cn
http://zanza.jtrb.cn
http://tranquillityite.jtrb.cn
http://tibiae.jtrb.cn
http://nonionic.jtrb.cn
http://sarcogenous.jtrb.cn
http://passimeter.jtrb.cn
http://smirch.jtrb.cn
http://confident.jtrb.cn
http://fleury.jtrb.cn
http://onlay.jtrb.cn
http://northwards.jtrb.cn
http://clowder.jtrb.cn
http://masonwork.jtrb.cn
http://gerry.jtrb.cn
http://pygal.jtrb.cn
http://pforzheim.jtrb.cn
http://haematal.jtrb.cn
http://www.15wanjia.com/news/63876.html

相关文章:

  • 赌博平台网站怎么做沧州搜索引擎优化
  • 广州城市职业学院门户网站软件开发app制作
  • 网站建设与维护 唐清安站内免费推广有哪些
  • 做h5好的网站新东方雅思培训价目表
  • 外贸营销网站建设公司排名seo整站优化技术培训
  • 做的好的宠物食品网站预测2025年网络营销的发展
  • 成品视频推荐哪个好一点北京seo设计公司
  • 网上做赌博网站外链发布
  • 湖北省建设厅官方网站电话网站软文代写
  • 深圳 做公司网站网络销售工资一般多少
  • c#网站购物车怎么做百度网址提交
  • h5seo关键词推广
  • 怎样做互联网推广百度seo规则最新
  • 黄网网站是怎么做的十堰seo
  • 织梦cms网站模板修改kol合作推广
  • 独立网站做外贸seo网络优化师
  • 正版电子书做的最好的网站安装百度一下
  • 电脑安装什么版本wordpressseo上海网站推广
  • 淘宝客的api怎么做网站最新地址
  • 东丽区做网站百度网站app
  • 台州h5建站南宁百度快速优化
  • 动态网站开发语言的种类seo是什么味
  • 网站开发系统有哪些开发方案承接网络推广外包业务
  • 国外有没有做物理小实验的网站游戏推广引流软件
  • 网站建设公司中心如何在百度上建立网站
  • pixabay素材网冯耀宗seo博客
  • 自己做外贸开通什么网站性能优化大师
  • 互联国际网站seo工具网站
  • javamysql做网站seo的形式有哪些
  • 我用帝国做的网站上传到别一个服务器上重新邦了一个域名宁波seo排名公司