Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ TiDB standard test suite.
- [sql-bench](./sql-bench)
- [sysbench](./sysbench)
- [TPC-C](./tpcc)

- OLAP Benchmark
- [TPC-DS](./tpcds)
- [TPC-H](./tpch)
- [Star Schema Benchmark](./ssb)
1 change: 1 addition & 0 deletions ssb/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.o
45 changes: 45 additions & 0 deletions ssb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Star Schema Benchmark

## Introduction

- [dbgen](./dbgen) comes from [electrum/ssb-dbgen](https://github.com/electrum/ssb-dbgen), thanks to [electrum](https://github.com/electrum)
- What is SSB: [Star Schema Benchmark](https://www.cs.umb.edu/~poneil/StarSchemaB.PDF)

## Build

```sh
cd dbgen
make -j8
cd ..
```

## Data Generation

```sh
cd dbgen
# "-s" is used to specify the volume of data to generate in GB.
# "-T a" indicates dbgen to generate data for all tables.
./dbgen -s 1 -T a
cd ..
```

## DataBase and Table schema generation
```sh
mysql -h 127.0.0.1 -P 4000 -u root -e "drop database if exists ssb;"
mysql -h 127.0.0.1 -P 4000 -u root -e "create database ssb;"
mysql -h 127.0.0.1 -P 4000 -u root -D ssb < create_table.sql
```

## Load Data

```sh
mysql --local-infile=1 -h 127.0.0.1 -P 4000 -u root -D ssb -e "load data local infile 'dbgen/part.tbl' into table part fields terminated by '|' lines terminated by '\n';"
mysql --local-infile=1 -h 127.0.0.1 -P 4000 -u root -D ssb -e "load data local infile 'dbgen/supplier.tbl' into table supplier fields terminated by '|' lines terminated by '\n';"
mysql --local-infile=1 -h 127.0.0.1 -P 4000 -u root -D ssb -e "load data local infile 'dbgen/customer.tbl' into table customer fields terminated by '|' lines terminated by '\n';"
mysql --local-infile=1 -h 127.0.0.1 -P 4000 -u root -D ssb -e "load data local infile 'dbgen/date.tbl' into table date fields terminated by '|' lines terminated by '\n';"
mysql --local-infile=1 -h 127.0.0.1 -P 4000 -u root -D ssb -e "load data local infile 'dbgen/lineorder.tbl' into table lineorder fields terminated by '|' lines terminated by '\n';"
```

## Run Queries

There are 13 queries in the star schema benchmark, located in [queries](./queries)
81 changes: 81 additions & 0 deletions ssb/create_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
create table part (
p_partkey bigint,
p_name varchar(30),
p_mfgr char(10),
p_category char(10),
p_brand1 char(10),
p_color varchar(20),
p_type varchar(30),
p_size bigint,
p_container char(10),
primary key(p_partkey)
);

create table supplier(
s_suppkey bigint,
s_name char(30),
s_address varchar(30),
s_city char(20),
s_natios_nationn char(20),
s_region char(20),
s_phone char(20),
primary key(s_suppkey)
);

create table customer(
c_custkey bigint,
c_name varchar(30),
c_address varchar(30),
c_city char(20),
c_nation char(20),
c_regioc_regionn char(20),
c_phone char(20),
c_mktsegment char(20),
primary key(c_custkey)
);

create table date(
d_datekey bigint,
d_date char(20),
d_dayofweek char(10),
d_month char(10),
d_year bigint,
d_yearmonthnum bigint,
d_yearmonth char(10),
d_daynuminmonth bigint,
d_daynuminyear bigint,
d_monthnuminyear bigint,
d_weeknuminyear bigint,
d_sellingseason char(20),
d_lastdayinweekfl bigint,
d_lastdayinmonthfl bigint,
d_holidayfl bigint,
d_weekdayfl bigint,
primary key(d_datekey)
);

create table lineorder (
lo_orderkey bigint,
lo_linenumber bigint,
lo_custkey bigint,
lo_partkey bigint,
lo_suppkey bigint,
lo_orderdate bigint,
lo_orderpriority char(20),
wlo_shippriority char(1),
lo_quantity bigint,
lo_extendedprice bigint,
lo_ordtotalprice bigint,
lo_discount bigint,
lo_revenue bigint,
lo_supplycost bigint,
lo_tax bigint,
lo_commitdate bigint,
lo_shipmode char(10),
primary key(lo_orderkey, lo_linenumber),
constraint foreign key lineorder_fk1(lo_custkey) references customer(c_custkey),
constraint foreign key lineorder_fk2(lo_partkey) references part(p_partkey),
constraint foreign key lineorder_fk3(lo_suppkey) references supplier(s_suppkey),
constraint foreign key lineorder_fk4(lo_orderdate) references date(d_datekey),
constraint foreign key lineorder_fk5(lo_commitdate) references date(d_datekey)
);
Loading