Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: tpc-c support for spanner #586

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
52 changes: 52 additions & 0 deletions config/spanner/sample_tpcc_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0"?>
<parameters>

<!-- Connection details -->
<type>SPANNER</type>
<driver>com.google.cloud.spanner.jdbc.JdbcDriver</driver>
<url>jdbc:cloudspanner://localhost:9010/projects/benchbase-project/instances/benchbase-instance/databases/benchbase;usePlainText=true</url>
<isolation>TRANSACTION_SERIALIZABLE</isolation>
<batchsize>128</batchsize>

<!-- Scale factor is the number of warehouses in TPCC -->
<scalefactor>1</scalefactor>

<!-- The workload -->
<terminals>1</terminals>
<works>
<work>
<time>60</time>
<rate>1500</rate>
<weights>45,43,4,4,4</weights>
</work>
</works>

<!-- TPCC specific -->
<transactiontypes>
<transactiontype>
<name>NewOrder</name>
<!--<preExecutionWait>18000</preExecutionWait>-->
<!--<postExecutionWait>12000</postExecutionWait>-->
</transactiontype>
<transactiontype>
<name>Payment</name>
<!--<preExecutionWait>3000</preExecutionWait>-->
<!--<postExecutionWait>12000</postExecutionWait>-->
</transactiontype>
<transactiontype>
<name>OrderStatus</name>
<!--<preExecutionWait>2000</preExecutionWait>-->
<!--<postExecutionWait>10000</postExecutionWait>-->
</transactiontype>
<transactiontype>
<name>Delivery</name>
<!--<preExecutionWait>2000</preExecutionWait>-->
<!--<postExecutionWait>5000</postExecutionWait>-->
</transactiontype>
<transactiontype>
<name>StockLevel</name>
<!--<preExecutionWait>2000</preExecutionWait>-->
<!--<postExecutionWait>5000</postExecutionWait>-->
</transactiontype>
</transactiontypes>
</parameters>
120 changes: 120 additions & 0 deletions src/main/resources/benchmarks/tpcc/ddl-spanner.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
CREATE TABLE warehouse (
W_ID INT64 NOT NULL,
W_YTD FLOAT64 NOT NULL,
W_TAX FLOAT64 NOT NULL,
W_NAME STRING(10) NOT NULL,
W_STREET_1 STRING(20) NOT NULL,
W_STREET_2 STRING(20) NOT NULL,
W_CITY STRING(20) NOT NULL,
W_STATE STRING(2) NOT NULL,
W_ZIP STRING(9) NOT NULL
) PRIMARY KEY (W_ID);

CREATE TABLE item (
I_ID INT64 NOT NULL,
I_NAME STRING(24) NOT NULL,
I_PRICE FLOAT64 NOT NULL,
I_DATA STRING(50) NOT NULL,
I_IM_ID INT64 NOT NULL
) PRIMARY KEY (I_ID);

CREATE TABLE stock (
S_W_ID INT64 NOT NULL,
S_I_ID INT64 NOT NULL,
S_QUANTITY INT64 NOT NULL,
S_YTD FLOAT64 NOT NULL,
S_ORDER_CNT INT64 NOT NULL,
S_REMOTE_CNT INT64 NOT NULL,
S_DATA STRING(50) NOT NULL,
S_DIST_01 STRING(24) NOT NULL,
S_DIST_02 STRING(24) NOT NULL,
S_DIST_03 STRING(24) NOT NULL,
S_DIST_04 STRING(24) NOT NULL,
S_DIST_05 STRING(24) NOT NULL,
S_DIST_06 STRING(24) NOT NULL,
S_DIST_07 STRING(24) NOT NULL,
S_DIST_08 STRING(24) NOT NULL,
S_DIST_09 STRING(24) NOT NULL,
S_DIST_10 STRING(24) NOT NULL
) PRIMARY KEY (S_W_ID, S_I_ID);

CREATE TABLE district (
D_W_ID INT64 NOT NULL,
D_ID INT64 NOT NULL,
D_YTD FLOAT64 NOT NULL,
D_TAX FLOAT64 NOT NULL,
D_NEXT_O_ID INT64 NOT NULL,
D_NAME STRING(10) NOT NULL,
D_STREET_1 STRING(20) NOT NULL,
D_STREET_2 STRING(20) NOT NULL,
D_CITY STRING(20) NOT NULL,
D_STATE STRING(2) NOT NULL,
D_ZIP STRING(9) NOT NULL
) PRIMARY KEY (D_W_ID, D_ID);

CREATE TABLE customer (
C_W_ID INT64 NOT NULL,
C_D_ID INT64 NOT NULL,
C_ID INT64 NOT NULL,
C_DISCOUNT FLOAT64 NOT NULL,
C_CREDIT STRING(2) NOT NULL,
C_LAST STRING(16) NOT NULL,
C_FIRST STRING(16) NOT NULL,
C_CREDIT_LIM FLOAT64 NOT NULL,
C_BALANCE FLOAT64 NOT NULL,
C_YTD_PAYMENT FLOAT64 NOT NULL,
C_PAYMENT_CNT INT64 NOT NULL,
C_DELIVERY_CNT INT64 NOT NULL,
C_STREET_1 STRING(20) NOT NULL,
C_STREET_2 STRING(20) NOT NULL,
C_CITY STRING(20) NOT NULL,
C_STATE STRING(2) NOT NULL,
C_ZIP STRING(9) NOT NULL,
C_PHONE STRING(16) NOT NULL,
C_SINCE TIMESTAMP NOT NULL,
C_MIDDLE STRING(2) NOT NULL,
C_DATA STRING(500) NOT NULL
) PRIMARY KEY (C_W_ID, C_D_ID, C_ID);

CREATE INDEX idx_customer_name ON customer (C_W_ID, C_D_ID, C_LAST, C_FIRST);

CREATE TABLE history (
H_C_W_ID INT64 NOT NULL,
H_C_D_ID INT64 NOT NULL,
H_C_ID INT64 NOT NULL,
H_D_ID INT64 NOT NULL,
H_W_ID INT64 NOT NULL,
H_DATE TIMESTAMP NOT NULL,
H_AMOUNT FLOAT64 NOT NULL,
H_DATA STRING(24) NOT NULL
) PRIMARY KEY (H_C_W_ID, H_C_D_ID, H_C_ID, H_DATE);

CREATE TABLE oorder (
O_W_ID INT64 NOT NULL,
O_D_ID INT64 NOT NULL,
O_ID INT64 NOT NULL,
O_C_ID INT64 NOT NULL,
O_CARRIER_ID INT64,
O_OL_CNT INT64 NOT NULL,
O_ALL_LOCAL INT64 NOT NULL,
O_ENTRY_D TIMESTAMP NOT NULL
) PRIMARY KEY (O_W_ID, O_D_ID, O_ID);

CREATE TABLE new_order (
NO_W_ID INT64 NOT NULL,
NO_D_ID INT64 NOT NULL,
NO_O_ID INT64 NOT NULL
) PRIMARY KEY (NO_W_ID, NO_D_ID, NO_O_ID);

CREATE TABLE order_line (
OL_W_ID INT64 NOT NULL,
OL_D_ID INT64 NOT NULL,
OL_O_ID INT64 NOT NULL,
OL_NUMBER INT64 NOT NULL,
OL_I_ID INT64 NOT NULL,
OL_DELIVERY_D TIMESTAMP,
OL_AMOUNT FLOAT64 NOT NULL,
OL_SUPPLY_W_ID INT64 NOT NULL,
OL_QUANTITY FLOAT64 NOT NULL,
OL_DIST_INFO STRING(24) NOT NULL
) PRIMARY KEY (OL_W_ID, OL_D_ID, OL_O_ID, OL_NUMBER);
19 changes: 19 additions & 0 deletions src/main/resources/benchmarks/tpcc/dialect-spanner.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<dialects>
<dialect type="SPANNER">
<procedure name="NewOrder">
<statement name="stmtGetDistSQL">
SELECT D_NEXT_O_ID, D_TAX
FROM district
WHERE D_W_ID = ? AND D_ID = ?
</statement>
<statement name="stmtGetStockSQL">
SELECT S_QUANTITY, S_DATA, S_DIST_01, S_DIST_02, S_DIST_03, S_DIST_04, S_DIST_05,
S_DIST_06, S_DIST_07, S_DIST_08, S_DIST_09, S_DIST_10
FROM stock
WHERE S_I_ID = ?
AND S_W_ID = ?
</statement>
</procedure>
</dialect>
</dialects>