mysql BLOB TEXT数据类型存储
对于BLOG与TEXT类型的字段,数据也不一定会放在BLOB页中。
如create table t4(v1 blog) charset=latin1
插入4条数据insert into t4 select repeat('a',8000);
其数据依然存放在数据页中。
page offset 00000003, page type [B-tree Node], page level [0001]
page offset 00000004, page type [B-tree Node], page level [0000]
page offset 00000005, page type [B-tree Node], page level [0000]
page offset 00000006, page type [B-tree Node], page level [0000]
page offset 00000000, page type [Freshly Allocated Page]
如果插入的数据为insert into t4 select repeat('a',20000);
数据会被放入BLOB页中
page offset 00000003, page type [B-tree Node], page level [0000]
page offset 00000004, page type [Uncompressed BLOB Page]
page offset 00000005, page type [Uncompressed BLOB Page]
page offset 00000006, page type [Uncompressed BLOB Page]
page offset 00000007, page type [Uncompressed BLOB Page]
page offset 00000008, page type [Uncompressed BLOB Page]
page offset 00000009, page type [Uncompressed BLOB Page]
page offset 0000000a, page type [Uncompressed BLOB Page]
page offset 0000000b, page type [Uncompressed BLOB Page]
因些,大多数情况下BLOB数据还是会发生溢出,实际数据保存在BLOB页中,数据页中只保存数据的前768字节。这里之所以产生了8个BLOB页,是否是一页里要放入2条记录,而20000.0/16384=1.2,即一条记录要两页才能放下,也满足了一页里最好放两条记录的要求,所以4条记录是2*4=8页。