每秒570000的写入,MySQL如何实现?
一、需求
二、实现再分析
三、XeLabs TokuDB 介绍
内置了jemalloc 内存分配
引入更多的内置的TokuDB性能指标
支持Xtrabackup备份
引入ZSTD压缩算法
支持TokuDB的binlog_group_commit特性
四、测试表
loose_tokudb_cache_size=4G
loose_tokudb_directio=ON
loose_tokudb_fsync_log_period=1000
tokudb_commit_sync=0
CREATE TABLE `user_summary` (
`user_id` bigint( 20) unsigned NOT NULL COMMENT '用户id/手机号',
`weight` varchar( 5) DEFAULT NULL COMMENT '和码体重(KG)',
`level` varchar( 20) DEFAULT NULL COMMENT '重量级',
`beat_rate` varchar( 12) DEFAULT NULL COMMENT '击败率',
`level_num` int( 10) DEFAULT NULL COMMENT '同吨位人数',
UNIQUE KEY `u_user_id` ( `user_id`)
) ENGINE=TokuDB DEFAULT CHARSET=utf8
root@localhost [zst]>LOAD DATA INFILE '/u01/work/134-136.txt'
INTO TABLE user_summary(user_id, weight, level, beat_rate,level_num);
Query OK, 200000000 rows affected (5 min 48.30 sec)
Records: 200000000 Deleted: 0 Skipped: 0 Warnings: 0
root@localhost [zst]>select 200000000/(5*60+48.30);
+------------------------+
| 200000000/(5*60+48.30) |
+------------------------+
| 574217.6285 |
+------------------------+
1 row in set (0.00 sec)
-rw-r--r-- 1 root root 8.5G 11月 25 20:05 134-136.txt
-rw-r----- 1 mysql mysql 8.6K 11月 25 20:44 user_summary.frm
-rw-r----- 1 mysql mysql 3.5G 11月 25 20:51 user_summary_main_229_1_1d_B_0.tokudb
-rw-r----- 1 mysql mysql 35G 11月 25 23:29 user2_main_26a_1_1d_B_0.tokudb
-rw-r----- 1 mysql mysql 176G 11月 26 03:32 user5.ibd
root@localhost [zst]>CREATE TABLE `user3` (
-> `user_id` bigint(20) unsigned NOT NULL COMMENT '用户id/手机号',
-> `weight` varchar(5) DEFAULT NULL COMMENT '和码体重(KG)',
-> `level` varchar(20) DEFAULT NULL COMMENT '重量级',
-> `beat_rate` varchar(12) DEFAULT NULL COMMENT '击败率',
-> `level_num` int(10) DEFAULT NULL COMMENT '同吨位人数',
-> `id` bigint(20) NOT NULL AUTO_INCREMENT,
-> PRIMARY KEY (`id`),
-> UNIQUE KEY `u_user_id` (`user_id`)
-> ) ENGINE=TokuDB;
Query OK, 0 rows affected (0.03 sec)
root@localhost [zst]>LOAD DATA INFILE '/u01/work/134-136.txt' INTO TABLE user3(user_id, weight, level, beat_rate,level_num);
Query OK, 200000000 rows affected (22 min 43.62 sec)
Records: 200000000 Deleted: 0 Skipped: 0 Warnings: 0
五、测试环境说明
你「在看」吗?