留言代码爱情,婚庆司仪主持词,模具钢材网
antelope是innodb-base的文件格式,barracude是innodb-plugin后引入的文件格式,同时barracude也支持antelope文件格式。两者区别在于:
文件格式 | 支持行格式 | 特性 |
antelope
(innodb-base) |
row_format=compact
row_format=redundant |
compact和redumdant的区别在就是在于首部的存存内容区别。
compact的存储格式为首部为一个非null的变长字段长度列表 redundant的存储格式为首部是一个字段长度偏移列表(每个字段占用的字节长度及其相应的位移)。 在antelope中对于变长字段,低于768字节的,不会进行overflow page存储,某些情况下会减少结果集io. |
barracuda
(innodb-plugin) |
row_format=dynamic
row_format=compressed
|
这两者主要是功能上的区别功能上的。 另外在行里的变长字段和antelope的区别是只存20个字节,其它的overflow page存储。
另外这两都需要开启innodb_file_per_table=1 (这个特性对一些优化还是很有用的) |
备注:
这里有一点需要注意,如果要使用压缩,一定需要先使用innodb_file_format =barracuda格式,不然没作用。
下面我们看一下区别:
database changed
(testing)root@localhost [wubx]> create table t1
-> (c1 int primary key)
-> row_format=compressed
-> key_block_size=8;
query ok, 0 rows affected, 4 warnings (0.01 sec)
+———+——+———————————————————————–+
| level | code | message |
+———+——+———————————————————————–+
| warning | 1478 | innodb: key_block_size requires innodb_file_format > antelope. |
| warning | 1478 | innodb: ignoring key_block_size=8. |
| warning | 1478 | innodb: row_format=compressed requires innodb_file_format > antelope. |
| warning | 1478 | innodb: assuming row_format=compact. |
+———+——+———————————————————————–+
4 rows in set (0.00 sec)
从以上报错可以看出来不支持压缩。但看一下表结构如下:
+——-+———————————————————————————————————————————————–+
| table | create table |
+——-+———————————————————————————————————————————————–+
| t1 | create table t1 (
c1 int(11) not null,
primary key (c1)
) engine=innodb default charset=utf8 row_format=compressed key_block_size=8 |
+——-+———————————————————————————————————————————————–+
1 row in set (0.00 sec)
这个是比较坑的地方,所以在使用压缩需要注意。
(testing)root@localhost [wubx]> insert into t2 select * from t1;
query ok, 5417760 rows affected (37.12 sec)
records: 5417760 duplicates: 0 warnings: 0
创建支持压缩的表:
(testing)root@localhost [wubx]>set global innodb_file_format=barracuda;
(testing)root@localhost [wubx]>create table t3
(c1 int primary key)
row_format=compressed
key_block_size=8;
(testing)root@localhost [wubx]> insert into t3 select * from t1;
query ok, 5417760 rows affected (1 min 10.98 sec)
records: 5417760 duplicates: 0 warnings: 0
看一下表的物理大小如下:
-rw-rw—- 1 mysql mysql 136m jul 5 19:40 t1.ibd
-rw-rw—- 1 mysql mysql 8.4k jul 5 19:43 t2.frm
-rw-rw—- 1 mysql mysql 136m jul 5 19:44 t2.ibd
-rw-rw—- 1 mysql mysql 8.4k jul 5 19:46 t3.frm
-rw-rw—- 1 mysql mysql 96m jul 5 19:47 t3.ibd
可见t1, t2都没进行压缩, t3是支持压缩的。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
网友评论