MySQL每秒57萬的寫入,帶你裝逼,帶你飛 !!
閱讀本文大概需要 3.5 分鐘。
來自:網(wǎng)絡(luò)
一、需求
二、實現(xiàn)再分析
三、XeLabs TokuDB介紹
內(nèi)置了jemalloc 內(nèi)存分配
引入更多的內(nèi)置的TokuDB性能指標
支持Xtrabackup備份
引入ZSTD壓縮算法
支持TokuDB的binloggroupcommit特性
四、測試表
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 '同噸位人數(shù)',
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 '同噸位人數(shù)',
-> `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
五、測試環(huán)境說明
推薦閱讀:
國內(nèi)突然爆發(fā)暴力蠕蟲病毒!已有大量用戶中招:所有文件被刪
IDEA + Groovy腳本一鍵生成實體類,用法舒服,高效!
微信掃描二維碼,關(guān)注我的公眾號
朕已閱?

