Skip to content

Commit c212e02

Browse files
jcamachorbpkroth
andauthored
Add TPC-C + TPC-H support for SQL Server with tests (#147)
Co-authored-by: Brian Kroth <[email protected]>
1 parent 930b1d0 commit c212e02

File tree

12 files changed

+558
-3
lines changed

12 files changed

+558
-3
lines changed

.github/workflows/maven.yml

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
runs-on: ubuntu-latest
4343
strategy:
4444
matrix:
45-
profile: [ 'cockroachdb', 'mariadb', 'mysql', 'postgres', 'spanner', 'phoenix' ]
45+
profile: [ 'cockroachdb', 'mariadb', 'mysql', 'postgres', 'spanner', 'phoenix', 'sqlserver' ]
4646
steps:
4747
- name: Checkout repo
4848
uses: actions/checkout@v2
@@ -243,3 +243,66 @@ jobs:
243243
- name: Run benchmark
244244
run: |
245245
java -jar benchbase.jar -b ${{matrix.benchmark}} -c config/cockroachdb/sample_${{matrix.benchmark}}_config.xml --create=true --load=true --execute=true
246+
247+
sqlserver:
248+
needs: package-and-upload
249+
runs-on: ubuntu-latest
250+
strategy:
251+
matrix:
252+
# TODO: add more benchmarks
253+
benchmark: [ 'tpcc', 'tpch' ]
254+
services:
255+
sqlserver:
256+
image: mcr.microsoft.com/mssql/server:2019-latest
257+
env:
258+
ACCEPT_EULA: Y
259+
SA_PASSWORD: SApassword1
260+
options: >-
261+
--health-cmd "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P SApassword1 -b -Q 'SELECT 1;'"
262+
--health-interval 10s
263+
--health-timeout 5s
264+
--health-retries 5
265+
ports:
266+
- 1433:1433
267+
steps:
268+
- name: Download artifact
269+
uses: actions/download-artifact@v2
270+
with:
271+
name: benchbase-sqlserver
272+
273+
- name: Extract artifact
274+
run: |
275+
tar xvzf benchbase-sqlserver.tgz --strip-components=1
276+
277+
- name: Delete artifact
278+
run: |
279+
rm -rf benchbase-sqlserver.tgz
280+
281+
- name: Set up JDK
282+
uses: actions/setup-java@v2
283+
with:
284+
java-version: ${{env.JAVA_VERSION}}
285+
distribution: 'temurin'
286+
287+
- name: Setup database
288+
uses: docker://mcr.microsoft.com/mssql-tools:latest
289+
with:
290+
entrypoint: /opt/mssql-tools/bin/sqlcmd
291+
args: -U sa -P SApassword1 -S sqlserver -b -Q "CREATE DATABASE benchbase_${{ matrix.benchmark }};"
292+
293+
- name: Setup login
294+
uses: docker://mcr.microsoft.com/mssql-tools:latest
295+
with:
296+
entrypoint: /opt/mssql-tools/bin/sqlcmd
297+
args: -U sa -P SApassword1 -S sqlserver -Q "CREATE LOGIN benchuser01 WITH PASSWORD='P@ssw0rd';"
298+
299+
- name: Setup access
300+
uses: docker://mcr.microsoft.com/mssql-tools:latest
301+
with:
302+
entrypoint: /opt/mssql-tools/bin/sqlcmd
303+
args: -U sa -P SApassword1 -S sqlserver -b -Q "USE benchbase_${{ matrix.benchmark }}; CREATE USER benchuser01 FROM LOGIN benchuser01; EXEC sp_addrolemember 'db_owner', 'benchuser01';"
304+
305+
- name: Run benchmark
306+
# Note: user/pass should match those used in sample configs.
307+
run: |
308+
java -jar benchbase.jar -b ${{matrix.benchmark}} -c config/sqlserver/sample_${{matrix.benchmark}}_config.xml --create=true --load=true --execute=true
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0"?>
2+
<parameters>
3+
4+
<!-- Connection details -->
5+
<type>sqlserver</type>
6+
<driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>
7+
<url>jdbc:sqlserver://localhost:1433;encrypt=false;database=benchbase_tpcc;</url>
8+
<username>benchuser01</username>
9+
<password>P@ssw0rd</password>
10+
<isolation>TRANSACTION_SERIALIZABLE</isolation>
11+
<batchsize>128</batchsize>
12+
13+
<!-- Scale factor is the number of warehouses in TPCC -->
14+
<scalefactor>1</scalefactor>
15+
16+
<!-- The workload -->
17+
<terminals>1</terminals>
18+
<works>
19+
<work>
20+
<time>60</time>
21+
<rate>10000</rate>
22+
<weights>45,43,4,4,4</weights>
23+
</work>
24+
</works>
25+
26+
<!-- TPCC specific -->
27+
<transactiontypes>
28+
<transactiontype>
29+
<name>NewOrder</name>
30+
<!--<preExecutionWait>18000</preExecutionWait>-->
31+
<!--<postExecutionWait>12000</postExecutionWait>-->
32+
</transactiontype>
33+
<transactiontype>
34+
<name>Payment</name>
35+
<!--<preExecutionWait>3000</preExecutionWait>-->
36+
<!--<postExecutionWait>12000</postExecutionWait>-->
37+
</transactiontype>
38+
<transactiontype>
39+
<name>OrderStatus</name>
40+
<!--<preExecutionWait>2000</preExecutionWait>-->
41+
<!--<postExecutionWait>10000</postExecutionWait>-->
42+
</transactiontype>
43+
<transactiontype>
44+
<name>Delivery</name>
45+
<!--<preExecutionWait>2000</preExecutionWait>-->
46+
<!--<postExecutionWait>5000</postExecutionWait>-->
47+
</transactiontype>
48+
<transactiontype>
49+
<name>StockLevel</name>
50+
<!--<preExecutionWait>2000</preExecutionWait>-->
51+
<!--<postExecutionWait>5000</postExecutionWait>-->
52+
</transactiontype>
53+
</transactiontypes>
54+
</parameters>
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<?xml version="1.0"?>
2+
<parameters>
3+
4+
<!-- Connection details -->
5+
<type>sqlserver</type>
6+
<driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>
7+
<url>jdbc:sqlserver://localhost:1433;encrypt=false;database=benchbase_tpch;</url>
8+
<username>benchuser01</username>
9+
<password>P@ssw0rd</password>
10+
<isolation>TRANSACTION_SERIALIZABLE</isolation>
11+
<batchsize>1024</batchsize>
12+
13+
<scalefactor>0.1</scalefactor>
14+
15+
<!-- The workload -->
16+
<terminals>1</terminals>
17+
<works>
18+
<work>
19+
<serial>true</serial>
20+
<rate>unlimited</rate>
21+
<weights>1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1</weights>
22+
</work>
23+
<work>
24+
<serial>true</serial>
25+
<rate>unlimited</rate>
26+
<weights>0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1</weights>
27+
</work>
28+
<work>
29+
<serial>true</serial>
30+
<rate>unlimited</rate>
31+
<weights>1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0</weights>
32+
</work>
33+
</works>
34+
35+
<transactiontypes>
36+
<groupings>
37+
<grouping>
38+
<name>odd</name>
39+
<weights>1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0</weights>
40+
</grouping>
41+
<grouping>
42+
<name>even</name>
43+
<weights>0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1</weights>
44+
</grouping>
45+
</groupings>
46+
<transactiontype>
47+
<name>Q1</name>
48+
<id>1</id>
49+
</transactiontype>
50+
<transactiontype>
51+
<name>Q2</name>
52+
<id>2</id>
53+
</transactiontype>
54+
<transactiontype>
55+
<name>Q3</name>
56+
<id>3</id>
57+
</transactiontype>
58+
<transactiontype>
59+
<name>Q4</name>
60+
<id>4</id>
61+
</transactiontype>
62+
<transactiontype>
63+
<name>Q5</name>
64+
<id>5</id>
65+
</transactiontype>
66+
<transactiontype>
67+
<name>Q6</name>
68+
<id>6</id>
69+
</transactiontype>
70+
<transactiontype>
71+
<name>Q7</name>
72+
<id>7</id>
73+
</transactiontype>
74+
<transactiontype>
75+
<name>Q8</name>
76+
<id>8</id>
77+
</transactiontype>
78+
<transactiontype>
79+
<name>Q9</name>
80+
<id>9</id>
81+
</transactiontype>
82+
<transactiontype>
83+
<name>Q10</name>
84+
<id>10</id>
85+
</transactiontype>
86+
<transactiontype>
87+
<name>Q11</name>
88+
<id>11</id>
89+
</transactiontype>
90+
<transactiontype>
91+
<name>Q12</name>
92+
<id>12</id>
93+
</transactiontype>
94+
<transactiontype>
95+
<name>Q13</name>
96+
<id>13</id>
97+
</transactiontype>
98+
<transactiontype>
99+
<name>Q14</name>
100+
<id>14</id>
101+
</transactiontype>
102+
<transactiontype>
103+
<name>Q15</name>
104+
<id>15</id>
105+
</transactiontype>
106+
<transactiontype>
107+
<name>Q16</name>
108+
<id>16</id>
109+
</transactiontype>
110+
<transactiontype>
111+
<name>Q17</name>
112+
<id>17</id>
113+
</transactiontype>
114+
<transactiontype>
115+
<name>Q18</name>
116+
<id>18</id>
117+
</transactiontype>
118+
<transactiontype>
119+
<name>Q19</name>
120+
<id>19</id>
121+
</transactiontype>
122+
<transactiontype>
123+
<name>Q20</name>
124+
<id>20</id>
125+
</transactiontype>
126+
<transactiontype>
127+
<name>Q21</name>
128+
<id>21</id>
129+
</transactiontype>
130+
<transactiontype>
131+
<name>Q22</name>
132+
<id>22</id>
133+
</transactiontype>
134+
</transactiontypes>
135+
</parameters>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: '3.5'
2+
3+
services:
4+
5+
sqlserver:
6+
container_name: sqlserver
7+
hostname: sqlserver
8+
image: mcr.microsoft.com/mssql/server:2019-latest
9+
environment:
10+
ACCEPT_EULA: Y
11+
SA_PASSWORD: SApassword1
12+
ports:
13+
- "1433:1433"
14+
15+
# No sqlserver web UI provided for now.
16+
# See Also: Azure Data Studio
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker compose down --remove-orphans --volumes
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker system prune -a -f --volumes

docker/sqlserver-2019-latest/up.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker compose up -d

pom.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,19 @@
111111
</dependency>
112112
</dependencies>
113113
</profile>
114+
<profile>
115+
<id>sqlserver</id>
116+
<properties>
117+
<classifier>sqlserver</classifier>
118+
</properties>
119+
<dependencies>
120+
<dependency>
121+
<groupId>com.microsoft.sqlserver</groupId>
122+
<artifactId>mssql-jdbc</artifactId>
123+
<version>10.2.0.jre17</version>
124+
</dependency>
125+
</dependencies>
126+
</profile>
114127
</profiles>
115128

116129
<dependencies>

src/main/java/com/oltpbenchmark/catalog/HSQLDBCatalog.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,12 @@ private void init() throws SQLException, IOException {
138138
// INDEXES
139139
try (ResultSet idxRS = md.getIndexInfo(null, null, internalTableName, false, false)) {
140140
while (idxRS.next()) {
141+
int idxType = idxRS.getShort(7);
142+
if (idxType == DatabaseMetaData.tableIndexStatistic) {
143+
continue;
144+
}
141145
boolean idxUnique = !idxRS.getBoolean(4);
142146
String idxName = idxRS.getString(6);
143-
int idxType = idxRS.getShort(7);
144147
int idxColPos = idxRS.getInt(8) - 1;
145148
String idxColName = idxRS.getString(9);
146149
String sort = idxRS.getString(10);

src/main/java/com/oltpbenchmark/util/SQLUtil.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,9 +495,12 @@ private static AbstractCatalog getCatalogDirect(DatabaseType databaseType, Conne
495495

496496
try (ResultSet idx_rs = md.getIndexInfo(catalog, schema, table_name, false, false)) {
497497
while (idx_rs.next()) {
498+
int idx_type = idx_rs.getShort("TYPE");
499+
if (idx_type == DatabaseMetaData.tableIndexStatistic) {
500+
continue;
501+
}
498502
boolean idx_unique = (!idx_rs.getBoolean("NON_UNIQUE"));
499503
String idx_name = idx_rs.getString("INDEX_NAME");
500-
int idx_type = idx_rs.getShort("TYPE");
501504
int idx_col_pos = idx_rs.getInt("ORDINAL_POSITION") - 1;
502505
String idx_col_name = idx_rs.getString("COLUMN_NAME");
503506
String sort = idx_rs.getString("ASC_OR_DESC");

0 commit comments

Comments
 (0)