3. TokuDB Overview
â˘MySQL Like Storage Engine (MySQL, MariaDB, PerconaServer)
â˘Database Engine that more friendly than InnoDB
â˘TokuTek Product
â˘Open Source
â˘No Built for 32 bit
â˘Only for Linux Server
4. Traditional MySQL Engines
â˘MyISAM
âSupport nontransactional query
âNo Foreign Key Support
âTable Level Locking
âSimple
â˘InnoDB
âSupport Transaction and MVCC
âForeign Key Support
âRow Level Locking
âComplex
7. TokuDB vs InnoDB
TokuDB
InnoDB
Indexing
Use Fractal Binary Index
Use Binary Tree Index
Hot Indexing
Yes
No
Hot Column Changes
Yes
No
Data Compression
Up to 25x
2x
Fragmentation Immunity
Yes
No
Eliminate Slave Lag
Yes
No
Fast Loader
Yes
No
Fast Recovery Time
Yes
No
Foreign Key Support
No
Yes
8. Benefit of TokuDB
â˘Schema change w/o downtime
â˘Performances (Fewer Server & Faster)
â˘More data Compression (Data Volume)
â˘Efficiency of Server
â˘TokuDB may extends Storage Life
â˘TokuDB may take the same amount time with InnoDB to complete if data is small. However, in huge data, tokudb can give you quick result
10. Indexing
â˘TokuDB uses Fractal Index
âMuch faster than B-trees in > RAM workloads
âInnoDB and MyISAM use B-trees
âKey Idea is minimizing I/O Operation
12. B-Tree
â˘B-Tree are Fast at Sequential Insert
âRequire 1 Disk I/O because Data fit in memory
13. B-Tree
â˘B-Trees are Slow for High-Entropy Inserts
âRequire Many Disk I/O (because data not fit in memory)
â˘Insert Cost ďˇďˇ ď¸ ďś ď§ď§ ď¨ ďŚ BNOloglog
14. B-Tree
â˘New Created B-Trees Run Fast Range Queries
âBecause Data is put sequentially on Disk
â˘Aged B-Trees Run Slow Range Queries
16. Simplified Fractal Tree
â˘Make N Array of 2 ^ (N-1) Elemen
â˘Each Array is full or empty
â˘Each array is sorted
â˘For Example if there are 10 elements.
5
10
3
6
8
12
17
23
26
30
21. Fractal Tree Insertion
â˘Cost to merge 2 arrays of size X is O(X/B) block I/O
â˘Cost per element to merge is O(1/B) since O(X) elements were merged.
â˘Max # of times of each element is merged is O(log N).
â˘Average insert cost (I/O) is O
â˘It may takes more CPU cycles because of merge process
ďˇď¸ ďś ď§ď¨ ďŚ BNlog
22. Fractal Tree vs Binary Tree
⢠Example:
â 10^9 of 128 Byte Rows inserted
⢠N = 2 ^ 30, log(N)= 30
â 1MB Block Size
⢠1 Block ď 8192 rows (2^20/2^7). B = 8192
⢠Log (B) = 13
â B-Tree:
â Fractal Tree:
3
13
30
log
log
ď ď˝ ďˇ ďˇ
ď¸
ďś
ď§ ď§
ď¨
ďŚ
B
N
O
0,003
8192
log 13
ď ď˝ ďˇď¸
ďś
ď§ď¨
ďŚ
B
N
O
23. Fractal vs Binary Tree
InnoDB
TokuDB
Performance
Fast until index not fit in Memory
Start Fast, Stay Fast
Deletion
Not Free Hardisk.
Free Hardisk
Disk Block
64KB, Random IO
4MB, Sequential IO
Bottleneck
Disk (I/O)
CPU
27. Installing TokuDB
â˘Pre-requisite: Install MySQL First
â˘TokuDB Procedure:
1.Download TokuDB (Check the version of MySQL)
2.Upload to Server
3.Extract TokuDB
4.Make symbolic link from /path-to-tokudb-folder/mysql-5.5.38- tokudb-7.1.0-linux-x86_64 to /path-to-tokudb-folder/mysql
5.Make symbolic link from /path-to-tokudb-folder/mysql/support- files/mysql.server to /etc/init.d/mysql_toku
6.Edit Configuration /etc/init.d/mysql_toku
a.basedir=/opt/tokutek/mysql
b.datadir=/var/lib/mysql
7.Copy âha_tokudb.soâ from /path-to-tokudb-folder/mysql/lib/plugin to /usr/lib64/mysql/plugin/
28. Installing TokuDB
â˘TokuDB Procedure (Cont)
8.Login to Mysql server as root
9.Do Query Below:
a)INSTALL PLUGIN tokudb_trx SONAME 'ha_tokudb.so';
b)INSTALL PLUGIN tokudb_locks SONAME 'ha_tokudb.so';
c)INSTALL PLUGIN tokudb_lock_waits SONAME 'ha_tokudb.so';
d)DELETE FROM mysql.plugin WHERE NAME LIKE 'tokudb_user_data%';
e)INSTALL PLUGIN TokuDB SONAME 'ha_tokudb.so';
f)INSTALL PLUGIN tokudb_file_map SONAME 'ha_tokudb.so';
g)INSTALL PLUGIN tokudb_fractal_tree_info SONAME 'ha_tokudb.so';
h)INSTALL PLUGIN tokudb_fractal_tree_block_map SONAME 'ha_tokudb.so';
i)SET GLOBAL default_storage_engine=TokuDB;
10.Verify Installation by Query SHOW PLUGINS; and SHOW ENGINES;
29. Result
â˘Conversion Result
âCompression
â˘Input Data: InnoDB 1.0 GB
â˘Output : TokuDB 200MB and more files XD
30. Advanced Setting
â˘Edit /etc/my.cnf
âReduce innodb_buffer_pool_size (InnoDB) and key_cache_size (MyISAM)
âEspecially if converting tables
âtokudb_cache_size=?G
âDefaults to 50% of RAM, I recommend 80%
âtokudb_directio=1
â(We Tell that OS should not cache page requested by TokuDB)
âData is cache by tokudb cache
âIn Experiment I set innodb_buffer_pool_size about 40-50% memory.
31. Advanced Setting
â˘TokuDB Compression method
âTOKUDB_ZLIB - This compression is using zlib library and provides mid-range compression with medium CPU utilization.
âTOKUDB_QUICKLZ - This compression is using quicklz library and provides light compression with low CPU utilization.
âTOKUDB_LZMA - This compression is using lzma library and provides the highest compression with high CPU utilization.
âTOKUDB_UNCOMPRESSED - This option disables the compression.
â˘Default TokuDB 7.1 ď TOKUDB_ZLIB
â˘Query
create table t1 (
`ID` int(11) NOT NULL AUTO_INCREMENT
) engine=tokudb, row_format=
[tokudb_lzma | tokudb_zlib | tokudb_quicklz];
ALTER TABLE City ROW_FORMAT=TOKUDB_ZLIB;