MySQL中计算行的速度
我想知道MySQL是否在每次添加或删除行时存储和更新行总数,或者在询问时是否计算行数? 我问这个问题是因为,如果它重要的话,它将影响应用程序的速度。如果有200万行,统计需要时间吗? 那么它有什么作用呢? 谢谢。 :D
I wanted to know that does MySQL store and update the total number of rows each time a row is added or removed, or does it count rows when asked?
I'm asking this because, if it counts, it will impact applications with speed. If there are 2 million rows, it will take time to count?
So what does it do?
Thanks. :D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
取决于您的存储引擎。 MyISAM 跟踪行数,而 InnoDB 则进行计数。但您应该进行基准测试,看看它是否真的像您想象的那么慢。我认为您的应用程序中存在比计算行数更糟糕的查询 - 尤其如果需要很长时间。
Depends on your storage engine. MyISAM keeps track of the row count, while InnoDB counts. But you should rather benchmark and see if it is really as slow as you think. I would think that there are much worse queries in your application than counting rows - especially if it takes a long time.