mariadb的一些特性(<=10.4)
- 2019 年 10 月 4 日
- 筆記
最近在看看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 s1G; *************************** 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