Skip to content

Commit

Permalink
Add TPC-C + TPC-H support for SQL Server with tests (cmu-db#147)
Browse files Browse the repository at this point in the history
Co-authored-by: Brian Kroth <[email protected]>
  • Loading branch information
jcamachor and bpkroth authored Apr 23, 2022
1 parent 930b1d0 commit c212e02
Show file tree
Hide file tree
Showing 12 changed files with 558 additions and 3 deletions.
65 changes: 64 additions & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
profile: [ 'cockroachdb', 'mariadb', 'mysql', 'postgres', 'spanner', 'phoenix' ]
profile: [ 'cockroachdb', 'mariadb', 'mysql', 'postgres', 'spanner', 'phoenix', 'sqlserver' ]
steps:
- name: Checkout repo
uses: actions/checkout@v2
Expand Down Expand Up @@ -243,3 +243,66 @@ jobs:
- name: Run benchmark
run: |
java -jar benchbase.jar -b ${{matrix.benchmark}} -c config/cockroachdb/sample_${{matrix.benchmark}}_config.xml --create=true --load=true --execute=true
sqlserver:
needs: package-and-upload
runs-on: ubuntu-latest
strategy:
matrix:
# TODO: add more benchmarks
benchmark: [ 'tpcc', 'tpch' ]
services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2019-latest
env:
ACCEPT_EULA: Y
SA_PASSWORD: SApassword1
options: >-
--health-cmd "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P SApassword1 -b -Q 'SELECT 1;'"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 1433:1433
steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: benchbase-sqlserver

- name: Extract artifact
run: |
tar xvzf benchbase-sqlserver.tgz --strip-components=1
- name: Delete artifact
run: |
rm -rf benchbase-sqlserver.tgz
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: ${{env.JAVA_VERSION}}
distribution: 'temurin'

- name: Setup database
uses: docker://mcr.microsoft.com/mssql-tools:latest
with:
entrypoint: /opt/mssql-tools/bin/sqlcmd
args: -U sa -P SApassword1 -S sqlserver -b -Q "CREATE DATABASE benchbase_${{ matrix.benchmark }};"

- name: Setup login
uses: docker://mcr.microsoft.com/mssql-tools:latest
with:
entrypoint: /opt/mssql-tools/bin/sqlcmd
args: -U sa -P SApassword1 -S sqlserver -Q "CREATE LOGIN benchuser01 WITH PASSWORD='P@ssw0rd';"

- name: Setup access
uses: docker://mcr.microsoft.com/mssql-tools:latest
with:
entrypoint: /opt/mssql-tools/bin/sqlcmd
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';"

- name: Run benchmark
# Note: user/pass should match those used in sample configs.
run: |
java -jar benchbase.jar -b ${{matrix.benchmark}} -c config/sqlserver/sample_${{matrix.benchmark}}_config.xml --create=true --load=true --execute=true
54 changes: 54 additions & 0 deletions config/sqlserver/sample_tpcc_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0"?>
<parameters>

<!-- Connection details -->
<type>sqlserver</type>
<driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>
<url>jdbc:sqlserver://localhost:1433;encrypt=false;database=benchbase_tpcc;</url>
<username>benchuser01</username>
<password>P@ssw0rd</password>
<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>10000</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>
135 changes: 135 additions & 0 deletions config/sqlserver/sample_tpch_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?xml version="1.0"?>
<parameters>

<!-- Connection details -->
<type>sqlserver</type>
<driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>
<url>jdbc:sqlserver://localhost:1433;encrypt=false;database=benchbase_tpch;</url>
<username>benchuser01</username>
<password>P@ssw0rd</password>
<isolation>TRANSACTION_SERIALIZABLE</isolation>
<batchsize>1024</batchsize>

<scalefactor>0.1</scalefactor>

<!-- The workload -->
<terminals>1</terminals>
<works>
<work>
<serial>true</serial>
<rate>unlimited</rate>
<weights>1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1</weights>
</work>
<work>
<serial>true</serial>
<rate>unlimited</rate>
<weights>0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1</weights>
</work>
<work>
<serial>true</serial>
<rate>unlimited</rate>
<weights>1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0</weights>
</work>
</works>

<transactiontypes>
<groupings>
<grouping>
<name>odd</name>
<weights>1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0</weights>
</grouping>
<grouping>
<name>even</name>
<weights>0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1</weights>
</grouping>
</groupings>
<transactiontype>
<name>Q1</name>
<id>1</id>
</transactiontype>
<transactiontype>
<name>Q2</name>
<id>2</id>
</transactiontype>
<transactiontype>
<name>Q3</name>
<id>3</id>
</transactiontype>
<transactiontype>
<name>Q4</name>
<id>4</id>
</transactiontype>
<transactiontype>
<name>Q5</name>
<id>5</id>
</transactiontype>
<transactiontype>
<name>Q6</name>
<id>6</id>
</transactiontype>
<transactiontype>
<name>Q7</name>
<id>7</id>
</transactiontype>
<transactiontype>
<name>Q8</name>
<id>8</id>
</transactiontype>
<transactiontype>
<name>Q9</name>
<id>9</id>
</transactiontype>
<transactiontype>
<name>Q10</name>
<id>10</id>
</transactiontype>
<transactiontype>
<name>Q11</name>
<id>11</id>
</transactiontype>
<transactiontype>
<name>Q12</name>
<id>12</id>
</transactiontype>
<transactiontype>
<name>Q13</name>
<id>13</id>
</transactiontype>
<transactiontype>
<name>Q14</name>
<id>14</id>
</transactiontype>
<transactiontype>
<name>Q15</name>
<id>15</id>
</transactiontype>
<transactiontype>
<name>Q16</name>
<id>16</id>
</transactiontype>
<transactiontype>
<name>Q17</name>
<id>17</id>
</transactiontype>
<transactiontype>
<name>Q18</name>
<id>18</id>
</transactiontype>
<transactiontype>
<name>Q19</name>
<id>19</id>
</transactiontype>
<transactiontype>
<name>Q20</name>
<id>20</id>
</transactiontype>
<transactiontype>
<name>Q21</name>
<id>21</id>
</transactiontype>
<transactiontype>
<name>Q22</name>
<id>22</id>
</transactiontype>
</transactiontypes>
</parameters>
16 changes: 16 additions & 0 deletions docker/sqlserver-2019-latest/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: '3.5'

services:

sqlserver:
container_name: sqlserver
hostname: sqlserver
image: mcr.microsoft.com/mssql/server:2019-latest
environment:
ACCEPT_EULA: Y
SA_PASSWORD: SApassword1
ports:
- "1433:1433"

# No sqlserver web UI provided for now.
# See Also: Azure Data Studio
3 changes: 3 additions & 0 deletions docker/sqlserver-2019-latest/down.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker compose down --remove-orphans --volumes
3 changes: 3 additions & 0 deletions docker/sqlserver-2019-latest/prune.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker system prune -a -f --volumes
3 changes: 3 additions & 0 deletions docker/sqlserver-2019-latest/up.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker compose up -d
13 changes: 13 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,19 @@
</dependency>
</dependencies>
</profile>
<profile>
<id>sqlserver</id>
<properties>
<classifier>sqlserver</classifier>
</properties>
<dependencies>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>10.2.0.jre17</version>
</dependency>
</dependencies>
</profile>
</profiles>

<dependencies>
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/oltpbenchmark/catalog/HSQLDBCatalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,12 @@ private void init() throws SQLException, IOException {
// INDEXES
try (ResultSet idxRS = md.getIndexInfo(null, null, internalTableName, false, false)) {
while (idxRS.next()) {
int idxType = idxRS.getShort(7);
if (idxType == DatabaseMetaData.tableIndexStatistic) {
continue;
}
boolean idxUnique = !idxRS.getBoolean(4);
String idxName = idxRS.getString(6);
int idxType = idxRS.getShort(7);
int idxColPos = idxRS.getInt(8) - 1;
String idxColName = idxRS.getString(9);
String sort = idxRS.getString(10);
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/oltpbenchmark/util/SQLUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,12 @@ private static AbstractCatalog getCatalogDirect(DatabaseType databaseType, Conne

try (ResultSet idx_rs = md.getIndexInfo(catalog, schema, table_name, false, false)) {
while (idx_rs.next()) {
int idx_type = idx_rs.getShort("TYPE");
if (idx_type == DatabaseMetaData.tableIndexStatistic) {
continue;
}
boolean idx_unique = (!idx_rs.getBoolean("NON_UNIQUE"));
String idx_name = idx_rs.getString("INDEX_NAME");
int idx_type = idx_rs.getShort("TYPE");
int idx_col_pos = idx_rs.getInt("ORDINAL_POSITION") - 1;
String idx_col_name = idx_rs.getString("COLUMN_NAME");
String sort = idx_rs.getString("ASC_OR_DESC");
Expand Down
Loading

0 comments on commit c212e02

Please sign in to comment.