Más contenido relacionado La actualidad más candente (20) Similar a MariaDB ColumnStore ベンチマークしちゃいませんか? (20) MariaDB ColumnStore ベンチマークしちゃいませんか?14. Transaction
ColumnStore vs InnoDB
sysbench
# sysbench --test=oltp --db-driver=mysql --mysql-socket=/usr/local/mariadb/columnstore/mysql/lib/mysql/mysql.sock
--num-threads=1 --max-requests=500 --max-time=0 --oltp-test-mode=complex --mysql-user=sbtest
--mysql-password=sbtest --oltp-test-mode=nontrx --oltp-nontrx-mode=insert run
※ columnstoreは並列度が1じゃないとlockエラーするのでnum-threads=1で比較
18. TPC-H Benchmark
検証環境
最小構成 検証環境
CPU 8 core Intel / AMD 8 core Intel (Core i7-4790K)
Memory 32GB 32GB
Storage 適切なRAID冗長構成を組んだローカル
ディスク、もしくはネットワーク接続スト
レージ。
240GB(RAID0)
対応OS RHEL/CentOS v6, v7
Ubuntu 16.04 LTS
Debian v8
SUSE 12
CentOS Linux
release 7.3.1611(Core)
22. TPC-H Benchmark
HammerDB 起動確認
起動
# cd /usr/local/HammerDB-2.23
# ./hammerora.tcl
起動時に下記エラーが出る場合
wish8.5: error while loading shared libraries: libXss.so.1: cannot open shared object
file: No such file or directory
# yum install libXScrnSaver
24. TPC-H Benchmark
HammerDB 初期値設定
<?xml version="1.0" encoding="utf-8">
<hammerdb>
...
<benchmark>
<rdbms>MySQL</rdbms>
<bm>TPC-H</bm>
</benchmark>
...
</hammerdb>
...
<mysql>
...
<tpch>
<schema>
<mysql_scale_fact>1</mysql_scale_fact>
<mysql_tpch_user>root</mysql_tpch_user>
<mysql_tpch_pass>root_password</mysql_tpch_pass>
<mysql_tpch_dbase>tpch</mysql_tpch_dbase>
<mysql_num_tpch_threads>1</mysql_num_tpch_threads>
<mysql_tpch_storage_engine>innodb</mysql_tpch_storage_engine>
</schema>
...
</tpch>
26. TPC-H Benchmark
InnoDBデータベース作成
MySQL Host 127.0.0.1
MySQL Port 3306
MySQL User root
MySQL User password rootのパスワード
MySQL Database tpch
Data Warehouse Storage engine innodb
Scale Factor 10
Virtual Users Build Schema 1
28. TPC-H Benchmark
ColumnStore データベース作成
InnoDB用 TPC-H データベースおよびテーブル確認
# mcsmysql -u root -p -D tpch
...
MariaDB [tpch]> show tables;
+----------------------+
| Tables_in_tpch |
+----------------------+
| customer |
| lineitem |
| nation |
| orders |
| part |
| partsupp |
| region |
| supplier |
+----------------------+
34. TPC-H Benchmark
Table行数
Table_schema Table_name Rows
tpch lineitem 58,025,902
tpch orders 14,807,501
tpch partsupp 9,691,914
tpch part 1,980,115
tpch customer 1,485,848
tpch supplier 99,036
tpch nation 25
tpch region 5
Scale Factor = 10
Virtual Users Build Schema = 1
Scale Factor=1 で作成した場合lineitemの行数が
600万行程度
エクステントマップが効かないので 10 で作成
※
※
35. TPC-H Benchmark
データサイズ確認
InnoDB
MariaDB [tpch_mcs]> use tpch;
...
MariaDB [tpch]> SELECT
table_schema ,
table_name ,
engine ,
table_rows AS tbl_rows ,
avg_row_length AS rlen ,
FORMAT( (data_length + index_length) / (1024*1024*1024), 2) AS All_GB ,
FORMAT( (data_length) / (1024*1024*1024), 2) AS Data_GB ,
FORMAT( (index_length) / (1024*1024*1024), 2) AS Index_GB
FROM information_schema.tables
WHERE TABLE_SCHEMA='tpch’
ORDER BY (data_length + index_length) DESC;
37. TPC-H Benchmark
データサイズ比較 (GB)
InnoDB ColumnStore
Table_schema Table_name Data Index Total Data Dict Total
tpch lineitem 7.83 7.55 15.38 3.03 1.94 4.97
tpch orders 1.84 0.59 2.42 0.61 1.38 1.99
tpch partsupp 1.93 0.19 2.11 0.22 1.00 1.22
tpch part 0.30 0.00 0.30 0.52 0.44 0.96
tpch customer 0.27 0.02 0.29 0.45 0.38 0.83
tpch supplier 0.02 0.00 0.02 0.01 0.13 0.14
tpch nation 0.01 0.00 0.01 0.01 0.01 0.01
tpch region 0.01 0.00 0.01 0.01 0.01 0.01
Total 20.54 10.13
40. TPC-H Benchmark
クエリ書き換え
Query # Error
Query 2 ERROR 1815 (HY000): Internal error: IDB-3012: Scalar filter and semi join are not from the same
pair of tables.
Query 5 ERROR 1815 (HY000): Internal error: IDB-1003: Circular joins are not supported.
Query 17 ERROR 1815 (HY000): Internal error: IDB-3012: Scalar filter and semi join are not from the same
pair of tables.
Query 19 ERROR 1815 (HY000): Internal error: IDB-1000: 'lineitem' and 'part' are not joined.
ColumnStoreで実行する場合クエリを書き換える必要がある
46. TPC-H Benchmark
hdb_tpch.tcl書き換え
#TPCH QUERY GENERATION
proc set_query { myposition } {
global sql
set sql(1) "select l_returnflag, l_linestatus, sum(l_quantity)…
set sql(2) "select s_acctbal, s_name, n_name, p_partkey, p_mfgr…
…
set sql(5) "select n_name, sum(l_extendedprice * (1 - l_discount)) …
…
set sql(17) "select sum(l_extendedprice) / 7.0 as avg_yearly from …
…
set sql(19) "select sum(l_extendedprice * (1 - l_discount)) as revenue …
…
set sql(22) "select cntrycode, count(*) as numcust, sum(c_acctbal) as
}
6,081 ~ 6,106 行目
49. TPC-H Benchmark
my.cnf 編集
# cd /usr/local/mariadb/columnstore/mysql
# vi my.conf
…
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 20GB
#innodb_additional_mem_pool_size = 20M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 100M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
InnoDBでベンチマーク時のみ有効にする
51. TPC-H Benchmark
ベンチマーク実行
MySQL Host 127.0.0.1
MySQL Port 3306
MySQL User root
MySQL User password rootのパスワード
MySQL Database tpch or tpch_mcs
Data Warehouse Storage engine innodb
Scale Factor 10
Virtual Users Build Schema 1
56. TPC-H Benchmark
ベンチマーク比較(sec)
Engine
Query
1 2 3 4 5 6 7 8 9 10 11
InnoDB 83.21 17.97 28.69 2.46 76.25 16.04 7.54 22.17 234.23 4.77 2.01
ColumnStore 7.74 1.38 1.87 7.86 2.82 0.63 8.29 1.81 8.02 2.32 0.39
Engine
Query
12 13 14 15 16 17 18 19 20 21 22
InnoDB 110.70 20.71 2.64 39.38 2.83 5.40 - 2.38 1.35 12.96 0.82
ColumnStore 1.43 4.02 1.05 1.36 1.37 12.48 6.69 3.45 3.36 12.32 4.67
62. TPC-H Benchmark
実行計画を取得する
Desc Mode Table TableOID ReferencedColumns PIO LIO PBE Elapsed Rows
BPS PM lineitem 4042 (L_DISCOUNT,
L_EXTENDEDPRICE,
L_LINESTATUS,
L_QUANTITY,
L_RETURNFLAG,
L_SHIPDATE, L_TAX)
136074 278562 0 7.451 488
TNS UM 7.354 4
Partition Blocks Eliminated
• エクステントマップにより読み飛ばしたブロックサイズ
• この値が0の場合、エクステントマップの恩恵を得られていない
Query 1 実行計画
65. エクステントマップ確認
editemプロセスから情報取得
[myuser@srv1~]# /usr/local/mariadb/columnstore/bin/editem -o 4043
Col OID = 4043, NumExtents = 8, width = 4
5306368 - 5310463 (4096) min: 130551998, max: 130987966, seqNum: 1,
state: valid, fbo: 0, DBRoot: 1, part#: 0, seg#: 0, HWM: 0; status: avail
5468160 - 5472255 (4096) min: 130551998, max: 130987966, seqNum: 1,
state: valid, fbo: 0, DBRoot: 1, part#: 0, seg#: 1, HWM: 0; status: unavail
5621760 - 5625855 (4096) min: 130551998, max: 130987966, seqNum: 1,
state: valid, fbo: 0, DBRoot: 1, part#: 0, seg#: 2, HWM: 0; status: unavail
…
66. TPC-H Benchmark
エクステントマップ確認
state Num min max seqNum fbo DBRoot part# seg# HWM
valid 5306368 - 5310463 (4096) 130551998 130987966 1 0 1 0 0 0
valid 5468160 - 5472255 (4096) 130551998 130987966 1 0 1 0 1 0
valid 5621760 - 5625855 (4096) 130551998 130987966 1 0 1 0 2 0
valid 5775360 - 5779455 (4096) 130551998 130987966 1 0 1 0 3 0
valid 5928960 - 5933055 (4096) 130551998 130987966 1 4096 1 0 0 8191
valid 6074368 - 6078463 (4096) 130551998 130987966 1 4096 1 0 1 8191
valid 6219776 - 6223871 (4096) 130551998 130987966 1 4096 1 0 2 8191
valid 6365184 - 6369279 (4096) 130551998 130987966 1 4096 1 0 3 4725
各エクステントの MIN/MAX値 が同値=絞り込み不可
lineitem テーブル l_shipdateカラム エクステントマップ詳細
71. mariadb-columnstore-samples
Flight data source
• mariadb-corporation/mariadb-columnstore-
samples
• https://github.com/mariadb-corporation/mariadb-
columnstore-samples/tree/master/flights
# このサンプルでは2016年のデータのみ
• 2013~2017 flight data
• https://downloads.mariadb.com/ColumnStore/sampledata
/flights/