InnoDB是否有静态表? [英] Does InnoDB have static tables?

查看:102
本文介绍了InnoDB是否有静态表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读MySQL文档,并且想知道 MyISAM的静态表格格式也适用于InnoDB吗?如果我使用 CHAR 而不是 VARCHAR ,而实际长度在0到100个字符之间变化,或者是使用 VARCHAR(100)更好?

I was reading MySQL documentation and I was wondering whether MyISAM's "static" table format also applies on InnoDB or not? Do I gain performance, if I use CHAR instead of VARCHAR when the real lengths varies between 0 and 100 characters or is using VARCHAR(100) better?

推荐答案

InnoDB确实具有以下优点:宽度行,并且将表中的所有列声明为固定宽度可能会有一些好处。主要优点是页面中的所有孔都可以重复用于任何插入,因为所有行的长度均相同。这使得空间再利用效率更高。不过,我不会尝试对超过几十个字节的任何字符串强制使用固定宽度,因为每页存储额外数据的成本(因此每页较少的行数)将很快使您从更多存储中获得的节省/收益无法承受有效地重新利用空间。

InnoDB does have fixed-width rows and there can be some advantage to declaring all columns in a table as fixed-width. The main benefit is that all "holes" in a page can be reused for any insertion, since all rows are the same length. This makes space re-use somewhat more efficient. I would not try to force fixed-width for any strings over a few dozen bytes though, as the cost of storing the extra data per page (and thus fewer rows per page) would quickly overwhelm any savings/gains you'd get from more efficient space re-usage.

但是,具有固定宽度的行并不能对行扫描进行任何优化(例如, MyISAM)。 InnoDB的行存储始终基于页面,并使用具有双向链接的页面列表和页面中的单链接记录的B +树。行遍历始终使用这些结构,无法通过其他任何方式完成。

However, having fixed-width rows does not allow for any optimization of row-scanning (like it does for MyISAM) whatsoever. InnoDB's row storage is always page-based and uses a B+tree with doubly-linked lists of pages, and singly-linked records within a page. Row traversal is always using these structures and can't be done any other way.

这篇关于InnoDB是否有静态表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆