MySQL 静态 (固定长度) 数据表 特性

对于 MyISAM 存储引擎,表默认的存储格式(storage format)为静态格式 (static format)。
当表中不包括可变长度的字段时(VARCHAR,VARBINARY,BLOB,TEXT),表中的每一行占用相同的固定长度。

一些特性:

  • 固定长度的表会提高性能,因为搜寻得会更快一些,因为这些固定的长度是很容易计算下一个数据的偏移量的,所以读取的自然也会很快。

To look up a row based on a row number in the index, multiply the row number by the row length to calculate the row position. Also, when scanning a table, it is very easy to read a constant number of rows with each disk read operation.

  • 更安全:

The security is evidenced if your computer crashes while the MySQL server is writing to a fixed-format MyISAM
file. In this case, myisamchk can easily determine where each row starts and ends, so it can usually reclaim all rows except the partially written one. MyISAM table indexes can always be reconstructed based on the data rows.

  • 更容易缓存

  • 含有 BLOB,TEXT 字段时,不使用 static format

  • 含有CHAR,VARCHAR 字段时,可以设置为 static format。此时, 字段为自动填充内容,以保持固定长度(space-padded to the specified column width

  • NULL 会占用一个 bit 的额外空间:

NULL columns require additional space in the row to record whether their values are NULL. Each NULL column takes one bit extra, rounded up to the nearest byte.

  • 不需要 OPTIMIZE TABLE

Reorganization is unnecessary unless you delete a huge number of rows and want to return free disk space to the operating system.


引用:
Static (Fixed-Length) Table Characteristics

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 背景 一年多以前我在知乎上答了有关LeetCode的问题, 分享了一些自己做题目的经验。 张土汪:刷leetcod...
    土汪阅读 12,768评论 0 33
  • 清晨八点多一点 走在校园 蝉鸣的声音有点黏 却黏不住昨天 偶然 飘来早饭的香甜 类似儿时赖床时 飘进卧室的温暖 而...
    宋予屿阅读 259评论 2 8
  • 时间一晃而过,转眼间我已经大三毕业了,但以前发生的一切都恍如梦境一般。还记得当初我刚上初二时,在一个新的班级里我对...
    600c6dee1372阅读 225评论 0 0
  • 識人不必探儘,探儘則多怨, 知人不必言儘,言儘則无友, 敬人不必卑儘,卑儘則少骨, 愛人不必我執,執儘則已亡 .....
    帶風走路deFENG阅读 363评论 0 1
  • 一、二叉树遍历 这里不细说原理了,如果不懂原理,赶紧去找Googe Baidu吧!别让他们等太久了 🏃! 接下来直...
    MangK阅读 2,374评论 0 4