12. * 記載されている会社名、サービス名、製品名は、株式会社インサイトテクノロジーおよび各社の商標または登録商標です。 Copyright 2018 Insight Technology, Inc. All Rights Reserved.
DWHといえば? カラムナー
Prod ID Prod Name
Prod ID Prod Name
Prod ID Prod Name
Prod ID Prod Name
Prod ID Prod Name
Date
Date
Date
Date
Date
Prod ID Prod Name
Prod ID Prod Name
Prod ID Prod Name
Prod ID Prod Name
Prod ID Prod Name
Date
Date
Date
Date
Date
1ブロックには様々な
タイプのデータが格納
されているので圧縮効
率を上げにくい
1ブロックには同様の
タイプのデータが格納
されているので圧縮効
率を上げやすい
通常のDB(行指向) 分析用DB(列指向)
13. * 記載されている会社名、サービス名、製品名は、株式会社インサイトテクノロジーおよび各社の商標または登録商標です。 Copyright 2018 Insight Technology, Inc. All Rights Reserved.
この差はカラムナーだけではない
0
2000
4000
6000
8000
10000
12000
14000
16000
18000
20000秒
TPC-H(SF=1000) クエリ実行時間
※monetdbが処理中にリソース不足でエラーとなったQ1, Q10, Q14を除いた実行時間
Vector
14. * 記載されている会社名、サービス名、製品名は、株式会社インサイトテクノロジーおよび各社の商標または登録商標です。 Copyright 2018 Insight Technology, Inc. All Rights Reserved.
CPUの使い方に一日の長あり
SIMD (Single Instruction Multiple Data)
Pentium ⅢよりSSE(Streaming SIMD Extensions)として搭載され、
Sandy BridgeよりIntel AVX(Advanced Vector eXtensions)へ
・・・
・・・
・・・
・・・
・・・
Instruction
Data
Output
15. * 記載されている会社名、サービス名、製品名は、株式会社インサイトテクノロジーおよび各社の商標または登録商標です。 Copyright 2018 Insight Technology, Inc. All Rights Reserved.
実行命令数の比較
27412968251
2.3858E+11
1.9685E+11
7.82182E+11
1.88149E+12 1.87184E+12
1
9 7
29
69
68
0
10
20
30
40
50
60
70
80
0.0E+00
1.0E+12
2.0E+12
Columnar DB
A
Columnar DB
B
In Memory DB
A
Rt = Instructions / (IPC * Hz * Parallelism)
Row Store DB
A
Row Store DB
B
CPUInstructions(count)
ComparisonvsVector
select
sum(l_extendedprice * l_discount) as revenue
from
lineitem -- 6億件, 80GB のデータ
where l_shipdate >= date '1996-01-01'
and l_shipdate < date '1996-01-01' + interval '1' year
and l_discount between 0.02 - 0.01 and 0.02 + 0.01
and l_quantity < 24
SIMD効果により、少ない命令数で済む
TPC-H Q6
16. * 記載されている会社名、サービス名、製品名は、株式会社インサイトテクノロジーおよび各社の商標または登録商標です。 Copyright 2018 Insight Technology, Inc. All Rights Reserved.
ブランチミス数の比較
1.8E+07
1.1E+09
3.0E+08
1.1E+09
1.6E+09
7.7E+08
1
64
17
62
88
43
0
10
20
30
40
50
60
70
80
90
100
0.0E+00
1.0E+09
2.0E+09
Columnar DB
A
Columnar DB
B
In Memory DB
A
Row Store DB
A
Row Store DB
B
Rt = Instructions / (IPC * Hz * Parallelism)
CPUBranch-Misses(count)
ComparisonvsVector
そもそも分岐命令数が1~2桁少ない。よってブランチミスのペナルティも少なくて済む。
17. * 記載されている会社名、サービス名、製品名は、株式会社インサイトテクノロジーおよび各社の商標または登録商標です。 Copyright 2018 Insight Technology, Inc. All Rights Reserved.
その結果がクエリの高速実行に
0.48 3.44
35.58
209.45
467.36
332.56
1
7
74
434
968
689
0
200
400
600
800
1000
1200
0
50
100
150
200
250
300
350
400
450
500
Columnar DB
A
Columnar DB
B
In Memory DB
A
Row Store DB
A
Row Store DB
B
Rt = Instructions / (IPC * Hz * Parallelism)
QueryElapsedTime(sec)
ComparisonvsVector
実行時間の比較
18. * 記載されている会社名、サービス名、製品名は、株式会社インサイトテクノロジーおよび各社の商標または登録商標です。 Copyright 2018 Insight Technology, Inc. All Rights Reserved.
メモリよりキャッシュ
• CPUキャッシュのアクセスはRAMよりも高速
• すべてのベクトルがCPUキャッシュ内に収まるように問合せの実行プランを作成
Latency
HDD 10 – 15 ms
SSD (SATA) 0.2 – 2 ms
SSD (NVMe) 10 – 100 us
RAM 50 – 100 ns
L3 Cache 10 – 20 ns
L2 Cache 3 – 10 ns
L1 Cache 1 ns
HW各構成要素のレイテンシ比較
19. * 記載されている会社名、サービス名、製品名は、株式会社インサイトテクノロジーおよび各社の商標または登録商標です。 Copyright 2018 Insight Technology, Inc. All Rights Reserved.
これらを組み合わせてx100は高速に
ベクター演算
カラムナー
データ自動圧縮CPUキャッシュ
マルチコア並列処理…
ストレージインデックス
Time/CyclestoProcess
Data Processed
DISK
RAM
CHIP
10GB2-3GB40-400MB
2-20150-250Millions
27. * 記載されている会社名、サービス名、製品名は、株式会社インサイトテクノロジーおよび各社の商標または登録商標です。 Copyright 2018 Insight Technology, Inc. All Rights Reserved.
Hadoopエコシステムと比べてみると…
select
100.00 * sum(case
when p_type like 'PROMO%’
then l_extendedprice * (1 - l_discount)
else 0
end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue
from
lineitem,
part
where
l_partkey = p_partkey
and l_shipdate >= date '1996-01-01’
and l_shipdate < date '1996-01-01' + interval '1' month
;
onVS
Q14(TPC-Hの中では極悪度かなり低め)
VS
小規模なデモ環境(CPU:
12core x 4node)でTPC-H
(SF=10)のQ14を実行し、
Hive on TEZおよびSpark SQL
と実行時間を比較してみ
る。
34. * 記載されている会社名、サービス名、製品名は、株式会社インサイトテクノロジーおよび各社の商標または登録商標です。 Copyright 2018 Insight Technology, Inc. All Rights Reserved.
その1:Spark側でVectorHテーブルを使う
Spark-Vector ConnectorによりSpark側で
VectorHのテーブルを読み書き可能
• SelectおよびInsert Select文
• HiveテーブルとのJOIN可能
• SQL構文はSpark側で解釈
spark.sqlContext.sql("""CREATE TEMPORARY VIEW vector_table
USING com.actian.spark_vector.sql.DefaultSource
OPTIONS (
host "192.168.99.121",
instance "VH",
database "tpch10",
user "actian",
password "actian",
table "customer"
)""")
val result=spark.sqlContext.sql("""select n.n_name, c.*
from vector_table c
join nation n where c.c_nationkey = n.n_nationkey limit 10""")
result.show()
Spark-Vector Connectorの使用例
35. * 記載されている会社名、サービス名、製品名は、株式会社インサイトテクノロジーおよび各社の商標または登録商標です。 Copyright 2018 Insight Technology, Inc. All Rights Reserved.
その2:Sparkの力を使った外部表
• Ver.5からSpark-providerサービスが登
場、Vector側からのSparkアクセスが可
能に。
• External TableとしてCSV、jsonなどSpark
が取り扱えるファイルを読み書き可能
• Hiveテーブルも認識可能
• VectorHテーブルとのJOIN可能
• SQL構文はVectorのパーサで解釈
CREATE EXTERNAL TABLE PART
(
P_PARTKEY INTEGER8 NOT NULL,
P_NAME VARCHAR(55) NOT NULL,
P_MFGR CHAR(25) NOT NULL,
P_BRAND CHAR(10) NOT NULL,
P_TYPE VARCHAR(25) NOT NULL,
P_SIZE INTEGER8 NOT NULL,
P_CONTAINER CHAR(10) NOT NULL,
P_RETAILPRICE DECIMAL(15,2) NOT NULL,
P_COMMENT VARCHAR(23) NOT NULL
)
USING SPARK
WITH REFERENCE=‘part’,
FORMAT=‘hive’
36. * 記載されている会社名、サービス名、製品名は、株式会社インサイトテクノロジーおよび各社の商標または登録商標です。 Copyright 2018 Insight Technology, Inc. All Rights Reserved.
さっきのクエリを外部表で実行してみる
select
100.00 * sum(case
when p_type like 'PROMO%’
then l_extendedprice * (1 - l_discount)
else 0
end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue
from
lineitem,
part
where
l_partkey = p_partkey
and l_shipdate >= date '1996-01-01’
and l_shipdate < date '1996-01-01' + interval '1' month
;
Q14
lineitemとpartを外部表にした
もの、partだけ外部表にして
VectorH上のlineitemとJOINし
たものを実行してみる。
37. * 記載されている会社名、サービス名、製品名は、株式会社インサイトテクノロジーおよび各社の商標または登録商標です。 Copyright 2018 Insight Technology, Inc. All Rights Reserved.
Hive / Sparkでは実行できないクエリも
select
nation,
o_year,
sum(amount) as sum_profit
from
(
select
n_name as nation,
extract(year from o_orderdate) as o_year,
l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount
from
part,
supplier,
lineitem,
partsupp,
orders,
nation
where
s_suppkey = l_suppkey
and ps_suppkey = l_suppkey
and ps_partkey = l_partkey
and p_partkey = l_partkey
and o_orderkey = l_orderkey
and s_nationkey = n_nationkey
and p_name like '%smoke%'
) as profit
group by
nation,
o_year
order by
nation,
o_year desc
;
Q9
Hive / Sparkはextract関数がない