Skip to content

Commit

Permalink
Benchmark BemiDB vs Postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
exAspArk committed Nov 5, 2024
1 parent 3f62e96 commit 27e2785
Show file tree
Hide file tree
Showing 29 changed files with 1,758 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/iceberg
/iceberg-test
.env
/benchmark/tpch-kit
/benchmark/data/*.tbl
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,12 @@ lint:

outdated:
devbox run "cd src && go list -u -m -f '{{if and .Update (not .Indirect)}}{{.}}{{end}}' all"

pg-init:
devbox run initdb

pg-up:
devbox services start postgresql

pg-down:
devbox services stop postgresql
74 changes: 74 additions & 0 deletions benchmark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# BemiDB Bechmark

## Running the TPC-H Benchmark

Set up a local PostgreSQL database:

```sh
# Install PostgreSQL
make pg-init
make pg-up

# Create the database
make sh
createdb tpch

# Load the tables' structure
cd ./benchmark/data
psql tpch -f ./structure.ddl

# Download and unzip "TPC-H_generated_data.zip" from the latest release into the "benchmark/data" directory
# And load the data
for i in `ls *.tbl`; do
table=${i/.tbl/}
echo "Loading $table..."
sed 's/|$//' $i > /tmp/$i
psql tpch -q -c "TRUNCATE $table"
psql tpch -c "\\copy $table FROM '/tmp/$i' CSV DELIMITER '|'"
done

# Run the queries
psql tpch -c "ANALYZE VERBOSE"
time psql tpch < ../queries.sql
```

## Generating the TPC-H Data

Install the TPC-H benchmark kit:

```sh
make sh
cd benchmark
git clone https://github.com/gregrahn/tpch-kit.git
cd tpch-kit/dbgen
make MACHINE=MACOS DATABASE=POSTGRESQL # Use MACHINE=LINUX for Linux
cd -
```

Copy tables' structure DDL file:

```sh
export DSS_PATH="$(pwd)/data"
export DSS_CONFIG=./tpch-kit/dbgen
cp ./tpch-kit/dbgen/dss.ddl ./data/structure.ddl
```

Generate the data:

```sh
./tpch-kit/dbgen/dbgen -vf -s 0.1 # Generate ~100MB of data
```

Generate the queries:

```sh
mkdir /tmp/query-templates
for i in `ls query-templates/*.sql`; do
tac $i | sed '2s/;//' | tac > /tmp/$i # Remove ";"
done

export DSS_QUERY=/tmp/query-templates
cd ./tpch-kit/dbgen
./qgen -v -s 0.1 | sed 's/limit -1//' | sed 's/day (3)/day/' > ../../queries.sql
cd -
```
70 changes: 70 additions & 0 deletions benchmark/data/structure.ddl
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
-- Sccsid: @(#)dss.ddl 2.1.8.1
CREATE TABLE NATION ( N_NATIONKEY INTEGER NOT NULL,
N_NAME CHAR(25) NOT NULL,
N_REGIONKEY INTEGER NOT NULL,
N_COMMENT VARCHAR(152));

CREATE TABLE REGION ( R_REGIONKEY INTEGER NOT NULL,
R_NAME CHAR(25) NOT NULL,
R_COMMENT VARCHAR(152));

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 );

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);

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 );

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);

CREATE TABLE ORDERS ( O_ORDERKEY INTEGER 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);

CREATE TABLE LINEITEM ( L_ORDERKEY INTEGER 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);

Loading

0 comments on commit 27e2785

Please sign in to comment.