mysql innodb 行数_mysql – 为什么InnoDB不存储行数?

我同意@RemusRusanu(1回答)

在InnoDB中,SELECT COUNT(*)FROM mydb.mytable的行为就像事务存储引擎一样.将它与MyISAM进行比较.

MyISAM数据

如果mydb.mytable是MyISAM表,则启动SELECT COUNT(*)FROM mydb.mytable;就像运行SELECT table_rows FROM information_schema.table WHERE table_schema =’mydb’AND table_name =’mytable’;.这会触发快速查找MyISAM表标题中的行计数.

InnoDB的

如果mydb.mytable是一个InnoDB表,你会得到大量的东西.你有MVCC正在进行,管理以下内容:

> ib_logfile0 / ib_logfile1(重做日志)

> ibdata1

>撤消日志

>回滚

>数据字典更改

>缓冲池管理

>交易隔离(4种类型)

>可重复读取

>阅读提交

>阅读未提交

>可序列化

询问InnoDB表的数量需要通过这些不祥的东西进行导航.实际上,人们从未真正知道mydb.mytable中的SELECT COUNT(*)是否只计算可重复读取,或者包括已提交的读取和未提交的读取.

When this variable is enabled (which is the default, as before the variable was created), InnoDB updates statistics during metadata statements such as SHOW TABLE STATUS or SHOW INDEX, or when accessing the INFORMATION_SCHEMA tables TABLES or STATISTICS. (These updates are similar to what happens for ANALYZE TABLE.) When disabled, InnoDB does not update statistics during these operations. Disabling this variable can improve access speed for schemas that have a large number of tables or indexes. It can also improve the stability of execution plans for queries that involve InnoDB tables.

在设置EXPLAIN计划方面,禁用它可能会也可能不会给您更稳定的计数.它可能以一种好的方式,坏方式或根本不影响mydb.mytable的SELECT COUNT(*)性能.试一试!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值