【Greenplum】TPC測(cè)試指南

【Greenplum】TPC性能測(cè)試指南

1叠必、準(zhǔn)備工作

1.1呆贿、Greenplum集群

集群版本 集群規(guī)格 集群節(jié)點(diǎn)數(shù) 分片數(shù) 測(cè)試類型
6.1.0 4C/32G/320G SSD 1P/1M/16Segment 4 TPC-B畏梆、TPC-C
6.1.0 4C/32G/320G SSD 1P/1M/32Segment 4 TPC-H

1.2击纬、測(cè)試參考

網(wǎng)絡(luò)鏈接
https://segmentfault.com/a/1190000022522888
https://segmentfault.com/a/1190000021947479/
https://cloud.tencent.com/developer/article/1344308

2牧氮、TPC-B

2.1去团、簡(jiǎn)介

TPC-B是由TPC(Transaction Processing Performance Council文搂,事務(wù)處理性能委員會(huì))提供的benchmark适刀,主要用于衡量一個(gè)系統(tǒng)每秒能夠處理的并發(fā)事務(wù)數(shù)。TPC-B不像TPC-C那樣模擬了現(xiàn)實(shí)生活中一個(gè)具體的交易場(chǎng)景煤蹭,其中的事務(wù)都是由簡(jiǎn)單SQL構(gòu)成的沒(méi)有語(yǔ)義的事務(wù)(事務(wù)中混雜了大表與小表的插入笔喉、更新與查詢操作),而且每個(gè)client的請(qǐng)求間也不會(huì)像TPC-C那樣會(huì)有一個(gè)human think time的間隔時(shí)間硝皂,而是一旦前一個(gè)事務(wù)執(zhí)行完成常挚,立馬會(huì)有下一個(gè)事務(wù)請(qǐng)求發(fā)出。因此稽物,TPC-B經(jīng)常用于對(duì)數(shù)據(jù)庫(kù)系統(tǒng)的事務(wù)性能壓測(cè)奄毡。TPC-B性能的衡量指標(biāo)是每秒處理的事務(wù)數(shù)量,即TPS(Transactions per Second)贝或。

2.2吼过、測(cè)試步驟

2.2.1、集群參數(shù)優(yōu)化(可選)

參數(shù) 參數(shù)值 說(shuō)明 參數(shù)設(shè)置方式
optimizer off 關(guān)閉針對(duì)AP場(chǎng)景的orca優(yōu)化器咪奖,對(duì)TP性能更友好盗忱。 gpconfig -c optimizer -v off
shared_buffers 8GB 將數(shù)據(jù)共享緩存調(diào)大。修改該參數(shù)需要重啟實(shí)例羊赵。 gpconfig -c shared_buffers -v 8GB
wal_buffers 256MB 將WAL日志緩存調(diào)大趟佃。修改該參數(shù)需要重啟實(shí)例。 gpconfig -c wal_buffers -v 256MB
log_statement none 將日志輸出關(guān)閉。 gpconfig -c log_statement -v none
random_page_cost 10 將隨機(jī)訪問(wèn)代價(jià)開(kāi)銷調(diào)小揖闸,有利于查詢走索引揍堕。 gpconfig -c random_page_cost -v 10
gp_resqueue_priority off 將resource queue關(guān)閉。需要重啟實(shí)例 gpconfig -c gp_resqueue_priority -v off
resource_scheduler off 將resource queue關(guān)閉汤纸。需要重啟實(shí)例 gpconfig -c resource_scheduler -v off
gp_enable_global_deadlock_detector on 控制是否開(kāi)啟全局死鎖檢測(cè)功能衩茸,打開(kāi)它才可以支持并發(fā)更新/刪除操作; gpconfig -c gp_enable_global_deadlock_detector -v on
checkpoint_segments 2 影響checkpoint主動(dòng)刷盤的頻率贮泞,針對(duì)OLTP大量更新類語(yǔ)句適當(dāng)調(diào)小此設(shè)置會(huì)增加刷盤頻率楞慈,平均性能會(huì)有較明顯提升; gpconfig -c checkpoint_segments -v 2 –skipvalidation

2.2.2啃擦、測(cè)試工具準(zhǔn)備

工具 安裝說(shuō)明
pgbench(version 9.5) 源碼安裝:下載開(kāi)源數(shù)據(jù)庫(kù)PostgreSQL源碼囊蓝,然后到pgbench對(duì)應(yīng)的目錄中單獨(dú)對(duì)pgbench進(jìn)行編譯生成可執(zhí)行的二進(jìn)制文件。
pgbench(version 9.5) 二進(jìn)制安裝:可以先直接yum install postgresql95-server來(lái)安裝PostgreSQL程序令蛉,此過(guò)程會(huì)自動(dòng)安裝pgbench工具聚霜。

2.2.3、測(cè)試數(shù)據(jù)準(zhǔn)備

測(cè)試數(shù)據(jù)總量

表名 數(shù)據(jù)量(行數(shù))
pgbench_accounts 1142400000
pgbench_branches 11424
pgbench_history 0
pgbench_tellers 114240

pgbench使用珠叔,填充因子為100蝎宇,比例因子為11424

# 其中-F參數(shù)就是上文說(shuō)的裝填因子,-s值得是比例因子
./pgbench -i -F 100 -s 11424 -p port -h host -U user_name -d db_name

2.2.4祷安、測(cè)試執(zhí)行

執(zhí)行TPC-B負(fù)載

# -c指定了連接數(shù)據(jù)庫(kù)client數(shù)量姥芥,-j指定了建立連接使用的線程數(shù)量,推薦將兩者設(shè)置成一樣
# -T指定了測(cè)試執(zhí)行時(shí)間汇鞭,單位為秒
./pgbench -h host -p port -r -n -c 96 -j 96 -T 120 -f all.sql -U user_name -d db_name

all.sql

\set scale 11424
\set nbranches 1 * :scale
\set ntellers 10 * :scale
\set naccounts 100000 * :scale
\setrandom aid 1 :naccounts
\setrandom bid 1 :nbranches
\setrandom tid 1 :ntellers
\setrandom delta -5000 5000
 
BEGIN;
 UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
 SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
 UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
 UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
 INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);
END;

執(zhí)行只讀負(fù)載

# -c指定了連接數(shù)據(jù)庫(kù)client數(shù)量凉唐,-j指定了建立連接使用的線程數(shù)量,推薦將兩者設(shè)置成一樣
# -T指定了測(cè)試執(zhí)行時(shí)間霍骄,單位為秒
./pgbench -h host -p port -r -n -c 96 -j 96 -T 120 -f select.sql -U user_name -d db_name

select.sql

\set scale 11424
\set naccounts 100000 * :scale
\setrandom aid 1 :naccounts
 
SELECT abalance FROM pgbench_accounts WHERE aid = :aid;

執(zhí)行只更新負(fù)載

# -c指定了連接數(shù)據(jù)庫(kù)client數(shù)量台囱,-j指定了建立連接使用的線程數(shù)量,推薦將兩者設(shè)置成一樣
# -T指定了測(cè)試執(zhí)行時(shí)間腕巡,單位為秒
./pgbench -h host -p port -r -n -c 96 -j 96 -T 120 -f update.sql -U user_name -d db_name

update.sql

\set scale 11424
\set naccounts 100000 * :scale
\setrandom aid 1 :naccounts
\setrandom delta -5000 5000
UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;

執(zhí)行只插入負(fù)載

# -c指定了連接數(shù)據(jù)庫(kù)client數(shù)量玄坦,-j指定了建立連接使用的線程數(shù)量,推薦將兩者設(shè)置成一樣
# -T指定了測(cè)試執(zhí)行時(shí)間绘沉,單位為秒
./pgbench -h host -p port -r -n -c 96 -j 96 -T 120 -f insert.sql -U user_name -d db_name

insert.sql

\set scale 11424
\set nbranches 1 * :scale
\set ntellers 10 * :scale
\set naccounts 100000 * :scale
\setrandom aid 1 :naccounts
\setrandom bid 1 :nbranches
\setrandom tid 1 :ntellers
\setrandom delta -5000 5000
INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);

3煎楣、TPC-C

3.1、簡(jiǎn)介

TPC-C是由TPC(Transaction Processing Performance Council车伞,事務(wù)處理性能委員會(huì))提供的專門針對(duì)聯(lián)機(jī)交易處理系統(tǒng)的規(guī)范择懂,TPC-C模擬的是一個(gè)大型的商品批發(fā)銷售公司交易負(fù)載。這個(gè)事務(wù)負(fù)載主要由9張表組成另玖,主要涉及5類交易類型:新訂單生成(New-Order)困曙、訂單支付(Payment)表伦、發(fā)貨(Delivery)、訂單狀態(tài)查詢(Order-Status)慷丽、和庫(kù)存狀態(tài)查詢(Stock-Level)蹦哼。TPC-C測(cè)試使用吞吐量指標(biāo)(Transaction per minute,簡(jiǎn)稱tpmC)來(lái)衡量系統(tǒng)的性能要糊,其中所統(tǒng)計(jì)的事務(wù)指的是新訂單生成的事務(wù)纲熏,即以每分鐘新訂單生成的事務(wù)數(shù)來(lái)衡量系統(tǒng)的性能指標(biāo)(在標(biāo)準(zhǔn)的TPC-C測(cè)試中,新訂單的事務(wù)數(shù)量占總事務(wù)數(shù)的45%左右)锄俄。

3.2局劲、測(cè)試步驟

3.2.1、集群參數(shù)優(yōu)化(可選)

參數(shù) 參數(shù)值 說(shuō)明 參數(shù)設(shè)置方式
optimizer off 關(guān)閉針對(duì)AP場(chǎng)景的orca優(yōu)化器奶赠,對(duì)TP性能更友好佛南。 gpconfig -c optimizer -v off
shared_buffers 8GB 將數(shù)據(jù)共享緩存調(diào)大搔谴。修改該參數(shù)需要重啟實(shí)例窗轩。 gpconfig -c shared_buffers -v 8GB
wal_buffers 256MB 將WAL日志緩存調(diào)大检痰。修改該參數(shù)需要重啟實(shí)例。 gpconfig -c wal_buffers -v 256MB
log_statement none 將日志輸出關(guān)閉竹祷。 gpconfig -c log_statement -v none
random_page_cost 10 將隨機(jī)訪問(wèn)代價(jià)開(kāi)銷調(diào)小谈跛,有利于查詢走索引羊苟。 gpconfig -c random_page_cost -v 10
gp_resqueue_priority off 將resource queue關(guān)閉塑陵。需要重啟實(shí)例 gpconfig -c gp_resqueue_priority -v off
resource_scheduler off 將resource queue關(guān)閉。需要重啟實(shí)例 gpconfig -c resource_scheduler -v off
gp_enable_global_deadlock_detector on 控制是否開(kāi)啟全局死鎖檢測(cè)功能蜡励,打開(kāi)它才可以支持并發(fā)更新/刪除操作令花; gpconfig -c gp_enable_global_deadlock_detector -v on
checkpoint_segments 2 影響checkpoint主動(dòng)刷盤的頻率,針對(duì)OLTP大量更新類語(yǔ)句適當(dāng)調(diào)小此設(shè)置會(huì)增加刷盤頻率凉倚,平均性能會(huì)有較明顯提升兼都; gpconfig -c checkpoint_segments -v 2 –skipvalidation

3.2.2、測(cè)試工具準(zhǔn)備

工具 安裝說(shuō)明
benchmarksql 軟件說(shuō)明:https://github.com/dreamedcheng/benchmarksql-5.0?spm=a2c4e.10696291.0.0.605719a4TUrbqS&file=benchmarksql-5.0

軟件安裝步驟:
git clone https://github.com/dreamedcheng/benchmarksql-5.0.git
yum install ant
cd benchmarksql-5.0
ant

3.2.3稽寒、測(cè)試數(shù)據(jù)準(zhǔn)備

測(cè)試數(shù)據(jù)總量

表名 數(shù)據(jù)量(行數(shù))
bmsql_warehouse 1000
bmsql_district 10000
bmsql_customer 30000000
bmsql_history 30000000
bmsql_new_order 9000000
bmsql_oorder 30000000
bmsql_order_line 299976737
bmsql_item 100000
bmsql_stock 100000000

使用benchmarksql工具生成1000個(gè)warehouse的數(shù)據(jù)集

· 創(chuàng)建測(cè)試用戶

CREATE USER benchmarksql WITH ENCRYPTED PASSWORD 'changeme';
CREATE DATABASE benchmarksql OWNER benchmarksql;

· 生成測(cè)試數(shù)據(jù)

-----------數(shù)據(jù)文件生成-----------
cd benchmarksql-5.0/run
./runLoader.sh gpdb.properties
       
       
-----------gpdb.properties文件內(nèi)容說(shuō)明-----------
db=postgres                                      // 使用默認(rèn)的postgres
driver=org.postgresql.Driver                     // 使用默認(rèn)的org.postgresql.Drive
conn=jdbc:postgresql://host:port/benchmarksql    //實(shí)例連接地址
user=benchmarksql                                // 連接實(shí)例的測(cè)試用戶
password=your_password                           // 對(duì)應(yīng)用戶的密碼
        
warehouses=1000                                  // 指定生成數(shù)據(jù)集warehouse的數(shù)量
loadWorkers=16                                   // 指定生成數(shù)據(jù)的線程數(shù)量扮碧,如果CPU core和內(nèi)存                                                     夠用可以將其大小調(diào)大,這樣速度更快
fileLocation=/data/tpcc_1000/                    // 指定生成數(shù)據(jù)的存儲(chǔ)目錄

數(shù)據(jù)加載

· 使用benchmarksql提供的tableCreates.sql進(jìn)行建表

psql -f tableCreates.sql -U user_name -d db_name -h host -p port

· 使用COPY命令導(dǎo)入數(shù)據(jù)

# 使用COPY方式將數(shù)據(jù)加載到數(shù)據(jù)庫(kù)中
psql -h host -d db_name -p your_port -U user_name -c "\copy bmsql_history from '/data/tpcc_1000/cust-hist.csv' with delimiter ',' null '';"

· 使用benchmarksql提供的indexCreates.sql進(jìn)行創(chuàng)建索引

psql -f indexCreates.sql -U user_name -d db_name -h host -p port

收集統(tǒng)計(jì)信息

analyze bmsql_warehouse;
analyze bmsql_district;
analyze bmsql_customer;
analyze bmsql_history;
analyze bmsql_new_order;
analyze bmsql_oorder;
analyze bmsql_order_line;
analyze bmsql_item;
analyze bmsql_stock;

3.3.4杏糙、測(cè)試執(zhí)行

-------------運(yùn)行測(cè)試腳本---------------
./runBenchmark.sh gpdb.properties
 
 
-----------gpdb.properties文件內(nèi)容說(shuō)明-----------
db=postgres                                              // 使用默認(rèn)的postgres
driver=org.postgresql.Driver                             // 使用默認(rèn)的org.postgresql.Drive
conn=jdbc:postgresql://host:port/benchmarksql            //adbpg實(shí)例連接地址
user=benchmarksql                                        // 連接adbpg實(shí)例測(cè)試的用戶
password=your_password                                   // 對(duì)應(yīng)用戶的密碼
 
terminals=128                                            // TPC-C測(cè)試的并發(fā)數(shù)
//To run specified transactions per terminal- runMins must equal zero
runTxnsPerTerminal=0                                     // 使用默認(rèn)的0
//To run for specified minutes- runTxnsPerTerminal must equal zero
runMins=10                                               // TPC-C執(zhí)行時(shí)間慎王,單位分鐘
//Number of total transactions per minute
limitTxnsPerMin=30000000                                 // 使用默認(rèn)的30000000
 
// 下面配置各個(gè)事務(wù)的比重,也使用如下給定的默認(rèn)值
//The following five values must add up to 100
//The default percentages of 45, 43, 4, 4 & 4 match the TPC-C spec
newOrderWeight=45
paymentWeight=43
orderStatusWeight=4
deliveryWeight=4
stockLevelWeight=4

4宏侍、TPC-H

4.1赖淤、簡(jiǎn)介

TPC-H(商業(yè)智能計(jì)算測(cè)試)是美國(guó)交易處理效能委員會(huì)(TPC,TransactionProcessing Performance Council) 組織制定的用來(lái)模擬決策支持類應(yīng)用的一個(gè)測(cè)試集。目前在學(xué)術(shù)界和工業(yè)界普遍采用它來(lái)評(píng)價(jià)決策支持技術(shù)方面應(yīng)用的性能谅河。TPC-H是根據(jù)真實(shí)的生產(chǎn)運(yùn)行環(huán)境來(lái)建模咱旱,模擬了一套銷售系統(tǒng)的數(shù)據(jù)倉(cāng)庫(kù)确丢。其共包含8個(gè)基本關(guān)系,數(shù)據(jù)量可設(shè)定從1G~3T不等吐限。其基準(zhǔn)測(cè)試共包含了22個(gè)查詢鲜侥,主要評(píng)價(jià)指標(biāo)各個(gè)查詢的響應(yīng)時(shí)間,即從提交查詢到結(jié)果返回所需時(shí)間诸典。其測(cè)試結(jié)果可綜合反映系統(tǒng)處理查詢時(shí)的能力剃毒。

4.2、測(cè)試步驟

4.2.1搂赋、測(cè)試工具準(zhǔn)備

工具 安裝說(shuō)明 使用說(shuō)明
TPC-H dbgen git clone https://github.com/gregrahn/tpch-kit.git
cd tpch-kit/dbgen
make MACHINE=LINUX DATABASE=POSTGRESQL
./dbgen -help
./qgen -help

4.2.2赘阀、測(cè)試數(shù)據(jù)準(zhǔn)備

測(cè)試數(shù)據(jù)總量:TPC-H 中使用SF描述數(shù)據(jù)量,1SF 對(duì)應(yīng)1GB 單位脑奠,1SF對(duì)應(yīng)的數(shù)據(jù)量只是8個(gè)表的總數(shù)據(jù)量不包括索引等空間占用基公,準(zhǔn)備數(shù)據(jù)時(shí)需預(yù)留更多空間,測(cè)試數(shù)據(jù)總量為1TB宋欺,即1000SF轰豆。

表名 數(shù)據(jù)條目數(shù)
customer 15000w
lineitem 5999989709
nation 25
orders 150000w
part 20000w
partsupp 80000w
region 5
supplier 1000w

測(cè)試數(shù)據(jù)文件生成
· 聲明環(huán)境變量

export DSS_CONFIG=/.../tpch-kit/dbgen              //tpch-kit/dbgen路徑
export DSS_QUERY=$DSS_CONFIG/queries
export DSS_PATH=/path-to-dir-for-output-files      //輸出文件保存路徑

· 方式一:直接生成1TB數(shù)據(jù)文件

cd tpch-kit/dbgen
./dbgen -vf -s 1000

· 方式二:并行生成分片文件

#生成數(shù)據(jù)文件
#10個(gè)分片文件
for((i=1;i<=10;i++));
do
   ./dbgen -s 1000 -S $i -C 10 -f &
done 
#處理生成的 tbl 文件,tbl文件每行最后會(huì)多1個(gè)'|'齿诞,可以用seed命令將每行后面的'|'去掉
sed -i 's/.$//' ./region.tbl &
sed -i 's/.$//' ./nation.tbl &
for((i=1;i<=10;i++));
do
   sed -i 's/.$//' ./lineitem.tbl.$i &
   sed -i 's/.$//' ./orders.tbl.$i &
   sed -i 's/.$//' ./customer.tbl.$i &
   sed -i 's/.$//' ./partsupp.tbl.$i &
   sed -i 's/.$//' ./part.tbl.$i &
   sed -i 's/.$//' ./supplier.tbl.$i &
done

建表語(yǔ)句

-- AO列存表酸休、不開(kāi)壓縮、設(shè)置復(fù)制表
 
create table nation (    
    n_nationkey  integer not null,    
    n_name       char(25) not null,    
    n_regionkey  integer not null,    
    n_comment    varchar(152))
with (appendonly=true, orientation=column)
distributed REPLICATED;
 
create table region (    
    r_regionkey  integer not null,    
    r_name       char(25) not null,    
    r_comment    varchar(152))
with (appendonly=true, orientation=column)
distributed REPLICATED;
 
create table part (    
    p_partkey     integer 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        integer not null,    
    p_container   char(10) not null,    
    p_retailprice DECIMAL(15,2) not null,    
    p_comment     varchar(23) not null)
with (appendonly=true, orientation=column)
distributed by (p_partkey);
 
create table supplier (    
    s_suppkey     integer not null,    
    s_name        char(25) not null,    
    s_address     varchar(40) not null,    
    s_nationkey   integer not null,    
    s_phone       char(15) not null,    
    s_acctbal     DECIMAL(15,2) not null,    
    s_comment     varchar(101) not null)
with (appendonly=true, orientation=column)
distributed by (s_suppkey);
 
create table partsupp (    
    ps_partkey     integer not null,    
    ps_suppkey     integer not null,    
    ps_availqty    integer not null,    
    ps_supplycost  DECIMAL(15,2)  not null,    
    ps_comment     varchar(199) not null)
with (appendonly=true, orientation=column)
distributed by (ps_partkey);
 
create table customer (    
    c_custkey     integer not null,    
    c_name        varchar(25) not null,    
    c_address     varchar(40) not null,    
    c_nationkey   integer not null,    
    c_phone       char(15) not null,    
    c_acctbal     DECIMAL(15,2)  not null,    
    c_mktsegment  char(10) not null,    
    c_comment     varchar(117) not null)
with (appendonly=true, orientation=column)
distributed by (c_custkey);
 
create table orders (    
    o_orderkey       bigint not null,    
    o_custkey        integer not null,    
    o_orderstatus    char(1) not null,    
    o_totalprice     DECIMAL(15,2) not null,    
    o_orderdate      date not null,    
    o_orderpriority  char(15) not null,    
    o_clerk          char(15) not null,    
    o_shippriority   integer not null,    
    o_comment        varchar(79) not null)
with (appendonly=true, orientation=column)
distributed by (o_orderkey);
 
create table lineitem (    
    l_orderkey    bigint not null,        
    l_partkey     integer not null,    
    l_suppkey     integer not null,    
    l_linenumber  integer not null,    
    l_quantity    DECIMAL(15,2) not null,    
    l_extendedprice  DECIMAL(15,2) not null,    
    l_discount    DECIMAL(15,2) not null,    
    l_tax         DECIMAL(15,2) not null,    
    l_returnflag  char(1) not null,    
    l_linestatus  char(1) not null,    
    l_shipdate    date not null,    
    l_commitdate  date not null,    
    l_receiptdate date not null,    
    l_shipinstruct char(25) not null,   
    l_shipmode     char(10) not null,    
    l_comment      varchar(44) not null)
with (appendonly=true, orientation=column)
distributed by (l_orderkey);

數(shù)據(jù)導(dǎo)入
· COPY方式導(dǎo)入祷杈,SQL腳本參考

\copy nation from '/data/tpch_1t/nation.tbl' DELIMITER '|';
\copy region from '/data/tpch_1t/region.tbl' DELIMITER '|';
\copy supplier from '/data/tpch_1t/supplier.tbl' DELIMITER '|';
\copy part from '/data/tpch_1t/part.tbl' DELIMITER '|';
\copy partsupp from '/data/tpch_1t/partsupp.tbl' DELIMITER '|';
\copy customer from '/data/tpch_1t/customer.tbl' DELIMITER '|';
\copy orders from '/data/tpch_1t/orders.tbl' DELIMITER '|';
\copy lineitem from '/data/tpch_1t/lineitem.tbl' DELIMITER '|';                          

1斑司、可以psql連接到數(shù)據(jù)庫(kù)后,依次單條執(zhí)行上述SQL語(yǔ)句
2但汞、直接執(zhí)行腳本文件宿刮,方式如下

psql -f copy.sql -U user_name -d db_name -h host -p port

· 利用對(duì)象存儲(chǔ)和外部表導(dǎo)入
1、將數(shù)據(jù)文件上傳至JSS上
2私蕾、創(chuàng)建外部表

create extension jss;
 
create readable external table ext_nation ( n_nationkey int, n_name varchar(25), n_regionkey integer, n_comment varchar(152)) 
LOCATION('')
FORMAT 'TEXT' (DELIMITER '|' ) ;
 
create readable external table ext_region ( R_REGIONKEY int, R_NAME CHAR(25),R_COMMENT VARCHAR(152)) 
LOCATION('')
FORMAT 'TEXT' (DELIMITER '|' ) ;
 
CREATE readable external TABLE ext_lineitem ( l_orderkey bigint, l_partkey bigint,     l_suppkey bigint, 
  l_linenumber bigint, l_quantity double precision, l_extendedprice double precision, 
  l_discount double precision, l_tax double precision, l_returnflag CHAR(1), 
  l_linestatus CHAR(1), l_shipdate DATE, l_commitdate DATE, l_receiptdate DATE, 
  l_shipinstruct CHAR(25), l_shipmode CHAR(10), l_comment VARCHAR(44)) 
LOCATION('') 
FORMAT 'TEXT' (DELIMITER '|' ) ;
 
CREATE readable external TABLE ext_orders ( o_orderkey bigint , o_custkey bigint, o_orderstatus CHAR(1) , 
o_totalprice double precision, o_orderdate DATE , o_orderpriority CHAR(15) , o_clerk CHAR(15) , 
o_shippriority bigint , o_comment VARCHAR(79) ) 
LOCATION('') 
FORMAT 'TEXT' (DELIMITER '|' ) ;
 
CREATE readable external TABLE ext_part ( p_partkey bigint , p_name VARCHAR(55) , p_mfgr CHAR(25) , 
  p_brand CHAR(10) , p_type VARCHAR(25) , p_size bigint , p_container CHAR(10) , 
  p_retailprice double precision , p_comment VARCHAR(23) ) 
LOCATION('') 
FORMAT 'TEXT' (DELIMITER '|' ) ;
 
CREATE readable external TABLE ext_partsupp ( ps_partkey bigint , ps_suppkey bigint , 
  ps_availqty bigint , ps_supplycost double precision , ps_comment VARCHAR(199) ) 
LOCATION('') 
FORMAT 'TEXT' (DELIMITER '|' ) ;
 
CREATE readable external TABLE ext_supplier ( s_suppkey bigint , s_name CHAR(25) , 
  s_address VARCHAR(40) , s_nationkey bigint , s_phone CHAR(15) , s_acctbal DECIMAL(15,2) , 
  s_comment VARCHAR(101) ) 
LOCATION('') 
FORMAT 'TEXT' (DELIMITER '|' ) ;
 
CREATE readable external TABLE ext_customer ( c_custkey bigint , c_name VARCHAR(25) , 
  c_address VARCHAR(40) , c_nationkey bigint , c_phone CHAR(15) , c_acctbal double precision , 
  c_mktsegment CHAR(10) , c_comment VARCHAR(117) ) 
LOCATION('') 
FORMAT 'TEXT' (DELIMITER '|' ) ;

3僵缺、將數(shù)據(jù)導(dǎo)入表中

insert into nation select * from ext_nation;
insert into region select * from ext_region;
insert into lineitem select * from ext_lineitem;
insert into orders select * from ext_orders;
insert into customer select * from ext_customer;
insert into part select * from ext_part;
insert into partsupp select * from ext_partsupp;
insert into supplier select * from ext_supplier;

收集統(tǒng)計(jì)信息

analyze nation;
analyze region;
analyze lineitem;
analyze orders;
analyze customer;
analyze part;
analyze partsupp;
analyze supplier;

4.2.3、測(cè)試執(zhí)行

· 生成測(cè)試22條測(cè)試sql

for ((i=1;i<=22;i++)); do
     ./qgen -v -c -s 1000 ${i} > /tmp/sf1000/tpch-q${i}.sql
done

· 執(zhí)行sql

  • 依次手動(dòng)執(zhí)行22條sql語(yǔ)句或利用腳本執(zhí)行
total_cost=0
 
for i in {1..22}
do
        echo "begin run Q${i}, /tmp/sf1000/tpch-q$i.sql , `date`"
        begin_time=`date +%s.%N`
        #psql -h ${實(shí)例連接地址} -p ${端口號(hào)} -U ${數(shù)據(jù)庫(kù)用戶} -f /tmp/sf1000/tpch-q${i}.sql > ./log/log_q${i}.out
        rc=$?
        end_time=`date +%s.%N`
        cost=`echo "$end_time-$begin_time"|bc`
        total_cost=`echo "$total_cost+$cost"|bc`
        if [ $rc -ne 0 ] ; then
              printf "run Q%s fail, cost: %.2f, totalCost: %.2f, `date`\n" $i $cost $total_cost
        else
              printf "run Q%s succ, cost: %.2f, totalCost: %.2f, `date`\n" $i $cost $total_cost
        fi
done
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末踩叭,一起剝皮案震驚了整個(gè)濱河市磕潮,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌容贝,老刑警劉巖自脯,帶你破解...
    沈念sama閱讀 218,122評(píng)論 6 505
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異嗤疯,居然都是意外死亡冤今,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,070評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門茂缚,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)戏罢,“玉大人屋谭,你說(shuō)我怎么就攤上這事」旮猓” “怎么了桐磁?”我有些...
    開(kāi)封第一講書人閱讀 164,491評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)讲岁。 經(jīng)常有香客問(wèn)我我擂,道長(zhǎng),這世上最難降的妖魔是什么缓艳? 我笑而不...
    開(kāi)封第一講書人閱讀 58,636評(píng)論 1 293
  • 正文 為了忘掉前任校摩,我火速辦了婚禮,結(jié)果婚禮上阶淘,老公的妹妹穿的比我還像新娘衙吩。我一直安慰自己,他們只是感情好溪窒,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,676評(píng)論 6 392
  • 文/花漫 我一把揭開(kāi)白布坤塞。 她就那樣靜靜地躺著,像睡著了一般澈蚌。 火紅的嫁衣襯著肌膚如雪摹芙。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書人閱讀 51,541評(píng)論 1 305
  • 那天宛瞄,我揣著相機(jī)與錄音浮禾,去河邊找鬼。 笑死坛悉,一個(gè)胖子當(dāng)著我的面吹牛伐厌,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播裸影,決...
    沈念sama閱讀 40,292評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼军熏!你這毒婦竟也來(lái)了轩猩?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書人閱讀 39,211評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤荡澎,失蹤者是張志新(化名)和其女友劉穎均践,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體摩幔,經(jīng)...
    沈念sama閱讀 45,655評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡彤委,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,846評(píng)論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了或衡。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片焦影。...
    茶點(diǎn)故事閱讀 39,965評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡车遂,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出斯辰,到底是詐尸還是另有隱情舶担,我是刑警寧澤,帶...
    沈念sama閱讀 35,684評(píng)論 5 347
  • 正文 年R本政府宣布彬呻,位于F島的核電站衣陶,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏闸氮。R本人自食惡果不足惜剪况,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,295評(píng)論 3 329
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望蒲跨。 院中可真熱鬧拯欧,春花似錦、人聲如沸财骨。這莊子的主人今日做“春日...
    開(kāi)封第一講書人閱讀 31,894評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)隆箩。三九已至该贾,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間捌臊,已是汗流浹背杨蛋。 一陣腳步聲響...
    開(kāi)封第一講書人閱讀 33,012評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留理澎,地道東北人逞力。 一個(gè)月前我還...
    沈念sama閱讀 48,126評(píng)論 3 370
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像糠爬,于是被迫代替她去往敵國(guó)和親寇荧。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,914評(píng)論 2 355