最近在看看MariaDB的官网上介绍MariaDB的功能和特性,大致罗列了本人觉得有必要了解下的几个地方:
支持到列级别的压缩
CREATE TABLE `cmp2` (
`id` bigint(20) NOT NULL,
`name` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`));
https://mariadb.com/kb/en/library/storage-engine-independent-column-compression/
支持sequence序列
CREATE SEQUENCE s1 START WITH 50;
SHOW CREATE SEQUENCE s1\G;
*************************** 1. row ***************************
Table: t1
Create Table: CREATE SEQUENCE `s1` start with 50 minvalue 1 maxvalue 9223372036854775806
increment by 1 cache 1000 nocycle ENGINE=Aria
CREATE SEQUENCE将创建一个序列,在使用NEXT VALUE FOR sequence_name调用时生成新值。当人们想要更多地控制数字的生成时,它是AUTO INCREMENT的替代品。由于SEQUENCE缓存值(高达CACHE),因此在某些情况下可以比AUTO INCREMENT快得多。另一个好处是可以访问所有使用的序列生成的最后一个值,这解决了LAST_INSERT_ID()的一个限制。
https://mariadb.com/kb/en/library/create-sequence/
Semisync 内置到server中,不再需要install plugin方式安装插件
mysql [localhost:10404] {root} (test) > show global variables like '%semi%';
+---------------------------------------+--------------+
| Variable_name | Value |
+---------------------------------------+--------------+
| rpl_semi_sync_master_enabled | OFF |
| rpl_semi_sync_master_timeout | 10000 |
| rpl_semi_sync_master_trace_level | 32 |
| rpl_semi_sync_master_wait_no_slave | ON |
| rpl_semi_sync_master_wait_point | AFTER_COMMIT |
| rpl_semi_sync_slave_delay_master | OFF |
| rpl_semi_sync_slave_enabled | OFF |
| rpl_semi_sync_slave_kill_conn_timeout | 5 |
| rpl_semi_sync_slave_trace_level | 32 |
+---------------------------------------+--------------+
9 rows in set (0.001 sec)
可以设置自动终止与空闲事务的连接
通过 idle_transaction_timeout,idle_readonly_transaction_timeout 和 idle_write_transaction_timeout 系统变量,
可以在指定的时间段后自动终止与空闲事务的连接。
mysql [localhost:10404] {root} (test) > show global variables like '%idle%transaction%';
+-----------------------------------+-------+
| Variable_name | Value |
+-----------------------------------+-------+
| idle_readonly_transaction_timeout | 0 |
| idle_transaction_timeout | 0 |
| idle_write_transaction_timeout | 0 |
+-----------------------------------+-------+
3 rows in set (0.001 sec)
支持 system-versioned 表
可以查看历史版本数据,贺春旸老师介绍过
https://blog.51cto.com/hcymysql/2121248
https://mariadb.com/kb/en/library/system-versioned-tables/
MariaDB 10.3支持update多表ORDER BY and LIMIT
自带了mariabackup 备份工具
mariadb10.3上, 有些独有的功能,例如innodb页面压缩,静态数据加密的功能。这在xtrabackup 上是不支持,只能用 mariabackup
具体的差异如下:
* MariaDB 10.1: With uncompressed and unencrypted MariaDB data, you can use XtraBackup.
If encryption or compression is used, or when innodb_page_size is set to some value other than 16K it will not work.
* MariaDB 10.2: You might also want to try to use XtraBackup, but be aware that problems are likely due to the MySQL 5.7
undo log format incompatibility bug that was fixed in MariaDB 10.2.2. Due to this bug, backups prepared with
XtraBackup may fail to recover some transactions. Only if you run the server with the setting innodb_undo_logs=1
this would not be a problem.
* MariaDB 10.3 and later: This case is more simple. XtraBackup is not compatible.
https://mariadb.com/kb/en/library/mariabackup-overview/
https://blog.51cto.com/hcymysql/2373581?source=dra
https://severalnines.com/blog/database-backups-comparing-mariadb-mariabackup-and-percona-xtrabackup
DDL快速失败
DDL WAIT and NOWAIT
DDL时候,如果拿不到锁就快速返回失败
https://mariadb.com/kb/en/library/wait-and-nowait/
增加了密码过期策略
CREATE USER 'monty'@'localhost' PASSWORD EXPIRE INTERVAL 120 DAY;
CREATE USER 'monty'@'localhost' PASSWORD EXPIRE NEVER;
https://mariadb.com/kb/en/library/user-password-expiry/
隐藏列
CREATE TABLE t (x INT, y INT INVISIBLE, z INT INVISIBLE NOT NULL DEFAULT 4);
INSERT INTO t VALUES (1),(2);
INSERT INTO t (x,y) VALUES (3,33);
SELECT * FROM t;
+------+
| x |
+------+
| 1 |
| 2 |
| 3 |
+------+
SELECT x,y,z FROM t;
+------+------+---+
| x | y | z |
+------+------+---+
| 1 | NULL | 4 |
| 2 | NULL | 4 |
| 3 | 33 | 4 |
+------+------+—+
https://mariadb.com/kb/en/library/invisible-columns/
窗口函数支持
https://mariadb.com/kb/en/window-functions/
支持WITH表达式(CTE)
BLOB和text字段也支持设置默认值
默认会尝试使用原子写入,不支持情况下就改用双写缓冲(目前看是支持宝存的SSD)https://mariadb.com/kb/en/library/atomic-write-support/
对MyRocks引擎的支持
tokudb被拆分为单独的包 mariadb-plugin-tokudb https://mariadb.com/kb/en/library/tokudb/
mysqlbinlog 支持 flashback参数, 实现DML的闪回 https://mariadb.com/kb/en/library/flashback/
AUTO_INCERMENT 持久化
支持压缩事件以减少二进制日志的大小
压缩是完全透明的。事件在写入二进制日志之前在主服务器上压缩,并且在写入中继日志之前由从服务器上的I / O线程解压缩。mysqlbinlog命令同样会为其输出解压缩事件。
当事件具有不可忽略的大小时,压缩将产生最大的影响,因为每个事件都是单独压缩的。例如,插入许多行或大值的批处理INSERT语句,或者在一个查询中触及多个行的基于行的事件。
https://mariadb.com/kb/en/library/compressing-events-to-reduce-size-of-the-binary-log/
binlog_format 在10.2.4后默认是mixed,最好我们还是改成row格式的
增加 JSON数据类型的支持
新增参数 read_binlog_speed_limit
允许限制slave从master读取binlog的速度(腾讯游戏提供code)
在某些情况下,从master读取binlog的速度很快,尤其是在创建新slave的时候,它会给master带来很高的流量。
https://jira.mariadb.org/browse/MDEV-11064