From 6006ab877cab6c5c0dbc5e70bddab60f0fafea66 Mon Sep 17 00:00:00 2001 From: Jesus Camacho Rodriguez Date: Wed, 24 Nov 2021 19:09:56 +0000 Subject: [PATCH 1/9] Add TPC-H support for SQL Server --- config/sqlserver/sample_tpch_config.xml | 143 +++++ pom.xml | 13 + .../java/com/oltpbenchmark/catalog/Table.java | 2 +- .../benchmarks/tpch/ddl-sqlserver.sql | 132 +++++ .../benchmarks/tpch/dialect-sqlserver.xml | 547 ++++++++++++++++++ 5 files changed, 836 insertions(+), 1 deletion(-) create mode 100644 config/sqlserver/sample_tpch_config.xml create mode 100644 src/main/resources/benchmarks/tpch/ddl-sqlserver.sql create mode 100644 src/main/resources/benchmarks/tpch/dialect-sqlserver.xml diff --git a/config/sqlserver/sample_tpch_config.xml b/config/sqlserver/sample_tpch_config.xml new file mode 100644 index 000000000..a62bca5de --- /dev/null +++ b/config/sqlserver/sample_tpch_config.xml @@ -0,0 +1,143 @@ + + + + + SQLSERVER + com.microsoft.sqlserver.jdbc.SQLServerDriver + jdbc:sqlserver://localhost:1433;encrypt=false; + benchuser01 + P@ssw0rd + TRANSACTION_SERIALIZABLE + 128 + + + data/tpch-sf0.01 + + + + tbl + + + 0.1 + + + 1 + + + true + unlimited + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 + + + true + unlimited + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1 + + + true + unlimited + 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0 + + + + + + + odd + 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0 + + + even + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1 + + + + Q1 + 1 + + + Q2 + 2 + + + Q3 + 3 + + + Q4 + 4 + + + Q5 + 5 + + + Q6 + 6 + + + Q7 + 7 + + + Q8 + 8 + + + Q9 + 9 + + + Q10 + 10 + + + Q11 + 11 + + + Q12 + 12 + + + Q13 + 13 + + + Q14 + 14 + + + Q15 + 15 + + + Q16 + 16 + + + Q17 + 17 + + + Q18 + 18 + + + Q19 + 19 + + + Q20 + 20 + + + Q21 + 21 + + + Q22 + 22 + + + diff --git a/pom.xml b/pom.xml index ab4dc03d4..e286d254f 100644 --- a/pom.xml +++ b/pom.xml @@ -111,6 +111,19 @@ + + sqlserver + + sqlserver + + + + com.microsoft.sqlserver + mssql-jdbc + 10.2.0.jre17 + + + diff --git a/src/main/java/com/oltpbenchmark/catalog/Table.java b/src/main/java/com/oltpbenchmark/catalog/Table.java index 8e545eb20..6a1d6e706 100644 --- a/src/main/java/com/oltpbenchmark/catalog/Table.java +++ b/src/main/java/com/oltpbenchmark/catalog/Table.java @@ -91,7 +91,7 @@ public void addIndex(Index index) { public Index getIndex(String indexName) { for (Index catalog_idx : this.indexes) { - if (catalog_idx.getName().equalsIgnoreCase(indexName)) { + if (indexName.equalsIgnoreCase(catalog_idx.getName())) { return (catalog_idx); } } diff --git a/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql b/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql new file mode 100644 index 000000000..ac110ab1a --- /dev/null +++ b/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql @@ -0,0 +1,132 @@ +DROP TABLE IF EXISTS lineitem; +DROP TABLE IF EXISTS orders; +DROP TABLE IF EXISTS customer; +DROP TABLE IF EXISTS partsupp; +DROP TABLE IF EXISTS part; +DROP TABLE IF EXISTS supplier; +DROP TABLE IF EXISTS nation; +DROP TABLE IF EXISTS region; + +CREATE TABLE region ( + r_regionkey integer NOT NULL, + r_name char(25) NOT NULL, + r_comment varchar(152), + PRIMARY KEY (r_regionkey) +); +CREATE UNIQUE INDEX r_rk ON region (r_regionkey ASC); + +CREATE TABLE nation ( + n_nationkey integer NOT NULL, + n_name char(25) NOT NULL, + n_regionkey integer NOT NULL, + n_comment varchar(152), + PRIMARY KEY (n_nationkey), + FOREIGN KEY (n_regionkey) REFERENCES region (r_regionkey) +); +CREATE UNIQUE INDEX n_nk ON nation (n_nationkey ASC); +CREATE INDEX n_rk ON nation (n_regionkey ASC); + +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, + PRIMARY KEY (p_partkey) +); +CREATE UNIQUE INDEX p_pk ON part (p_partkey ASC); + +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, + PRIMARY KEY (s_suppkey), + FOREIGN KEY (s_nationkey) REFERENCES nation (n_nationkey) +); +CREATE UNIQUE INDEX s_sk ON supplier (s_suppkey ASC); +CREATE INDEX s_nk ON supplier (s_nationkey ASC); + +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, + PRIMARY KEY (ps_partkey, ps_suppkey), + FOREIGN KEY (ps_partkey) REFERENCES part (p_partkey), + FOREIGN KEY (ps_suppkey) REFERENCES supplier (s_suppkey) +); +CREATE INDEX ps_pk ON partsupp (ps_partkey ASC); +CREATE INDEX ps_sk ON partsupp (ps_suppkey ASC); +CREATE UNIQUE INDEX ps_pk_sk ON partsupp (ps_partkey ASC, ps_suppkey ASC); +CREATE UNIQUE INDEX ps_sk_pk ON partsupp (ps_suppkey ASC, ps_partkey ASC); + +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, + PRIMARY KEY (c_custkey), + FOREIGN KEY (c_nationkey) REFERENCES nation (n_nationkey) +); +CREATE UNIQUE INDEX c_ck ON customer (c_custkey ASC); +CREATE INDEX c_nk ON customer (c_nationkey ASC); + +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, + PRIMARY KEY (o_orderkey), + FOREIGN KEY (o_custkey) REFERENCES customer (c_custkey) +); +CREATE UNIQUE INDEX o_ok ON orders (o_orderkey ASC); +CREATE INDEX o_ck ON orders (o_custkey ASC); +CREATE INDEX o_od ON orders (o_orderdate ASC); + +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, + PRIMARY KEY (l_orderkey, l_linenumber), + FOREIGN KEY (l_orderkey) REFERENCES orders (o_orderkey), + FOREIGN KEY (l_partkey, l_suppkey) REFERENCES partsupp (ps_partkey, ps_suppkey) +); +CREATE INDEX l_ok ON lineitem (l_orderkey ASC); +CREATE INDEX l_pk ON lineitem (l_partkey ASC); +CREATE INDEX l_sk ON lineitem (l_suppkey ASC); +CREATE INDEX l_sd ON lineitem (l_shipdate ASC); +CREATE INDEX l_cd ON lineitem (l_commitdate ASC); +CREATE INDEX l_rd ON lineitem (l_receiptdate ASC); +CREATE INDEX l_pk_sk ON lineitem (l_partkey ASC, l_suppkey ASC); +CREATE INDEX l_sk_pk ON lineitem (l_suppkey ASC, l_partkey ASC); diff --git a/src/main/resources/benchmarks/tpch/dialect-sqlserver.xml b/src/main/resources/benchmarks/tpch/dialect-sqlserver.xml new file mode 100644 index 000000000..85b675947 --- /dev/null +++ b/src/main/resources/benchmarks/tpch/dialect-sqlserver.xml @@ -0,0 +1,547 @@ + + + + + + select + l_returnflag, l_linestatus, sum(l_quantity) as sum_qty, + sum(l_extendedprice) as sum_base_price, + sum(l_extendedprice * (1 - l_discount)) as sum_disc_price, + sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge, + avg(l_quantity) as avg_qty, + avg(l_extendedprice) as avg_price, + avg(l_discount) as avg_disc, + count(*) as count_order + from + lineitem + where + l_shipdate <= dateadd(dd, -1 * ?, cast('1998-12-01' as datetime)) + group by + l_returnflag, + l_linestatus + order by + l_returnflag, + l_linestatus + + + + + select TOP 100 + s_acctbal, + s_name, + n_name, + p_partkey, + p_mfgr, + s_address, + s_phone, + s_comment + from + part, + supplier, + partsupp, + nation, + region + where + p_partkey = ps_partkey + and s_suppkey = ps_suppkey + and p_size = ? + and p_type like ? + and s_nationkey = n_nationkey + and n_regionkey = r_regionkey + and r_name = ? + and ps_supplycost = ( + select + min(ps_supplycost) + from + partsupp, + supplier, + nation, + region + where + p_partkey = ps_partkey + and s_suppkey = ps_suppkey + and s_nationkey = n_nationkey + and n_regionkey = r_regionkey + and r_name = ? + ) + order by + s_acctbal desc, + n_name, + s_name, + p_partkey + + + + + select TOP 10 + l_orderkey, + sum(l_extendedprice * (1 - l_discount)) as revenue, + o_orderdate, + o_shippriority + from + customer, + orders, + lineitem + where + c_mktsegment = ? + and c_custkey = o_custkey + and l_orderkey = o_orderkey + and o_orderdate < ? + and l_shipdate > ? + group by + l_orderkey, + o_orderdate, + o_shippriority + order by + revenue desc, + o_orderdate + + + + + select + o_orderpriority, + count(*) as order_count + from + orders + where + o_orderdate >= ? + and o_orderdate < dateadd(mm, 3, cast(? as datetime)) + and exists ( + select + * + from + lineitem + where + l_orderkey = o_orderkey + and l_commitdate < l_receiptdate + ) + group by + o_orderpriority + order by + o_orderpriority + + + + + select + n_name, + sum(l_extendedprice * (1 - l_discount)) as revenue + from + customer, + orders, + lineitem, + supplier, + nation, + region + where + c_custkey = o_custkey + and l_orderkey = o_orderkey + and l_suppkey = s_suppkey + and c_nationkey = s_nationkey + and s_nationkey = n_nationkey + and n_regionkey = r_regionkey + and r_name = ? + and o_orderdate >= ? + and o_orderdate < dateadd(YY, 1, cast(? as datetime)) + group by + n_name + order by + revenue desc + + + + + select + sum(l_extendedprice * l_discount) as revenue + from + lineitem + where + l_shipdate >= ? + and l_shipdate < dateadd(yy, 1, cast(? as datetime)) + and l_discount between ? - 0.01 and ? + 0.01 + and l_quantity < ? + + + + + select + supp_nation, + cust_nation, + l_year, + sum(volume) as revenue + from + ( + select + n1.n_name as supp_nation, + n2.n_name as cust_nation, + datepart(yy, l_shipdate) as l_year, + l_extendedprice * (1 - l_discount) as volume + from + supplier, + lineitem, + orders, + customer, + nation n1, + nation n2 + where + s_suppkey = l_suppkey + and o_orderkey = l_orderkey + and c_custkey = o_custkey + and s_nationkey = n1.n_nationkey + and c_nationkey = n2.n_nationkey + and ( + (n1.n_name = ? and n2.n_name = ?) + or (n1.n_name = ? and n2.n_name = ?) + ) + and l_shipdate between '1995-01-01' and '1996-12-31' + ) as shipping + group by + supp_nation, + cust_nation, + l_year + order by + supp_nation, + cust_nation, + l_year + + + + + select + o_year, + sum(case + when nation = ? then volume + else 0 + end) / sum(volume) as mkt_share + from + ( + select + datepart(yy,o_orderdate) as o_year, + l_extendedprice * (1 - l_discount) as volume, + n2.n_name as nation + from + part, + supplier, + lineitem, + orders, + customer, + nation n1, + nation n2, + region + where + p_partkey = l_partkey + and s_suppkey = l_suppkey + and l_orderkey = o_orderkey + and o_custkey = c_custkey + and c_nationkey = n1.n_nationkey + and n1.n_regionkey = r_regionkey + and r_name = ? + and s_nationkey = n2.n_nationkey + and o_orderdate between '1995-01-01' and '1996-12-31' + and p_type = ? + ) as all_nations + group by + o_year + order by + o_year + + + + + select + nation, + o_year, + sum(amount) as sum_profit + from + ( + select + n_name as nation, + datepart(yy, o_orderdate) as o_year, + l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount + from + part, + supplier, + lineitem, + partsupp, + orders, + nation + where + s_suppkey = l_suppkey + and ps_suppkey = l_suppkey + and ps_partkey = l_partkey + and p_partkey = l_partkey + and o_orderkey = l_orderkey + and s_nationkey = n_nationkey + and p_name like ? + ) as profit + group by + nation, + o_year + order by + nation, + o_year desc + + + + + select TOP 20 + c_custkey, + c_name, + sum(l_extendedprice * (1 - l_discount)) as revenue, + c_acctbal, + n_name, + c_address, + c_phone, + c_comment + from + customer, + orders, + lineitem, + nation + where + c_custkey = o_custkey + and l_orderkey = o_orderkey + and o_orderdate >= ? + and o_orderdate < dateadd(mm, 3, cast(? as datetime)) + and l_returnflag = 'R' + and c_nationkey = n_nationkey + group by + c_custkey, + c_name, + c_acctbal, + c_phone, + n_name, + c_address, + c_comment + order by + revenue desc + + + + + select + l_shipmode, + sum(case + when o_orderpriority = '1-URGENT' + or o_orderpriority = '2-HIGH' + then 1 + else 0 + end) as high_line_count, + sum(case + when o_orderpriority <> '1-URGENT' + and o_orderpriority <> '2-HIGH' + then 1 + else 0 + end) as low_line_count + from + orders, + lineitem + where + o_orderkey = l_orderkey + and l_shipmode in (?, ?) + and l_commitdate < l_receiptdate + and l_shipdate < l_commitdate + and l_receiptdate >= ? + and l_receiptdate < dateadd(mm, 1, cast(? as datetime)) + group by + l_shipmode + order by + l_shipmode + + + + + select + 100.00 * sum(case + when p_type like 'PROMO%' + then l_extendedprice * (1 - l_discount) + else 0 + end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue + from + lineitem, + part + where + l_partkey = p_partkey + and l_shipdate >= ? + and l_shipdate < dateadd(mm, 1, cast(? as datetime)) + + + + + create view revenue0 (supplier_no, total_revenue) as + select + l_suppkey, + sum(l_extendedprice * (1 - l_discount)) + from + lineitem + where + l_shipdate >= ? + and l_shipdate < dateadd(mm, 3, cast(? as datetime)) + group by + l_suppkey + + + + + select TOP 100 + c_name, + c_custkey, + o_orderkey, + o_orderdate, + o_totalprice, + sum(l_quantity) + from + customer, + orders, + lineitem + where + o_orderkey in ( + select + l_orderkey + from + lineitem + group by + l_orderkey having + sum(l_quantity) > ? + ) + and c_custkey = o_custkey + and o_orderkey = l_orderkey + group by + c_name, + c_custkey, + o_orderkey, + o_orderdate, + o_totalprice + order by + o_totalprice desc, + o_orderdate + + + + + select + s_name, + s_address + from + supplier, + nation + where + s_suppkey in ( + select + ps_suppkey + from + partsupp + where + ps_partkey in ( + select + p_partkey + from + part + where + p_name like ? + ) + and ps_availqty > ( + select + 0.5 * sum(l_quantity) + from + lineitem + where + l_partkey = ps_partkey + and l_suppkey = ps_suppkey + and l_shipdate >= ? + and l_shipdate < dateadd(yy, 1, cast(? as datetime)) + ) + ) + and s_nationkey = n_nationkey + and n_name = ? + order by + s_name + + + + + select TOP 100 + s_name, + count(*) as numwait + from + supplier, + lineitem l1, + orders, + nation + where + s_suppkey = l1.l_suppkey + and o_orderkey = l1.l_orderkey + and o_orderstatus = 'F' + and l1.l_receiptdate > l1.l_commitdate + and exists ( + select + * + from + lineitem l2 + where + l2.l_orderkey = l1.l_orderkey + and l2.l_suppkey <> l1.l_suppkey + ) + and not exists ( + select + * + from + lineitem l3 + where + l3.l_orderkey = l1.l_orderkey + and l3.l_suppkey <> l1.l_suppkey + and l3.l_receiptdate > l3.l_commitdate + ) + and s_nationkey = n_nationkey + and n_name = ? + group by + s_name + order by + numwait desc, + s_name + + + + + select + cntrycode, + count(*) as numcust, + sum(c_acctbal) as totacctbal + from + ( + select + substring(c_phone, 1, 2) as cntrycode, + c_acctbal + from + customer + where + substring(c_phone, 1, 2) in + (?, ?, ?, ?, ?, ?, ?) + and c_acctbal > ( + select + avg(c_acctbal) + from + customer + where + c_acctbal > 0.00 + and substring(c_phone, 1, 2) in + (?, ?, ?, ?, ?, ?, ?) + ) + and not exists ( + select + * + from + orders + where + o_custkey = c_custkey + ) + ) as custsale + group by + cntrycode + order by + cntrycode + + + + \ No newline at end of file From 823ee1b959af49574c47a5ee6433709a326f5377 Mon Sep 17 00:00:00 2001 From: Jesus Camacho Rodriguez Date: Thu, 7 Apr 2022 19:35:46 -0700 Subject: [PATCH 2/9] Addressing review comments --- config/sqlserver/sample_tpch_config.xml | 8 - .../oltpbenchmark/catalog/HSQLDBCatalog.java | 5 +- .../java/com/oltpbenchmark/catalog/Table.java | 2 +- .../java/com/oltpbenchmark/util/SQLUtil.java | 5 +- .../benchmarks/tpch/ddl-sqlserver.sql | 1 + .../benchmarks/tpch/dialect-sqlserver.xml | 491 +----------------- 6 files changed, 27 insertions(+), 485 deletions(-) diff --git a/config/sqlserver/sample_tpch_config.xml b/config/sqlserver/sample_tpch_config.xml index a62bca5de..546cd842b 100644 --- a/config/sqlserver/sample_tpch_config.xml +++ b/config/sqlserver/sample_tpch_config.xml @@ -10,14 +10,6 @@ TRANSACTION_SERIALIZABLE 128 - - data/tpch-sf0.01 - - - - tbl - - 0.1 diff --git a/src/main/java/com/oltpbenchmark/catalog/HSQLDBCatalog.java b/src/main/java/com/oltpbenchmark/catalog/HSQLDBCatalog.java index cd6eeba77..1c6b34a8e 100644 --- a/src/main/java/com/oltpbenchmark/catalog/HSQLDBCatalog.java +++ b/src/main/java/com/oltpbenchmark/catalog/HSQLDBCatalog.java @@ -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); diff --git a/src/main/java/com/oltpbenchmark/catalog/Table.java b/src/main/java/com/oltpbenchmark/catalog/Table.java index 6a1d6e706..8e545eb20 100644 --- a/src/main/java/com/oltpbenchmark/catalog/Table.java +++ b/src/main/java/com/oltpbenchmark/catalog/Table.java @@ -91,7 +91,7 @@ public void addIndex(Index index) { public Index getIndex(String indexName) { for (Index catalog_idx : this.indexes) { - if (indexName.equalsIgnoreCase(catalog_idx.getName())) { + if (catalog_idx.getName().equalsIgnoreCase(indexName)) { return (catalog_idx); } } diff --git a/src/main/java/com/oltpbenchmark/util/SQLUtil.java b/src/main/java/com/oltpbenchmark/util/SQLUtil.java index 8a3e29537..2aeb46dd5 100644 --- a/src/main/java/com/oltpbenchmark/util/SQLUtil.java +++ b/src/main/java/com/oltpbenchmark/util/SQLUtil.java @@ -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"); diff --git a/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql b/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql index ac110ab1a..1d68c84c3 100644 --- a/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql +++ b/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql @@ -1,3 +1,4 @@ +-- Adapted from the Postgres schema DROP TABLE IF EXISTS lineitem; DROP TABLE IF EXISTS orders; DROP TABLE IF EXISTS customer; diff --git a/src/main/resources/benchmarks/tpch/dialect-sqlserver.xml b/src/main/resources/benchmarks/tpch/dialect-sqlserver.xml index 85b675947..f788bf803 100644 --- a/src/main/resources/benchmarks/tpch/dialect-sqlserver.xml +++ b/src/main/resources/benchmarks/tpch/dialect-sqlserver.xml @@ -3,544 +3,87 @@ - select - l_returnflag, l_linestatus, sum(l_quantity) as sum_qty, - sum(l_extendedprice) as sum_base_price, - sum(l_extendedprice * (1 - l_discount)) as sum_disc_price, - sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge, - avg(l_quantity) as avg_qty, - avg(l_extendedprice) as avg_price, - avg(l_discount) as avg_disc, - count(*) as count_order - from - lineitem - where - l_shipdate <= dateadd(dd, -1 * ?, cast('1998-12-01' as datetime)) - group by - l_returnflag, - l_linestatus - order by - l_returnflag, - l_linestatus + select l_returnflag, l_linestatus, sum(l_quantity) as sum_qty, sum(l_extendedprice) as sum_base_price, sum(l_extendedprice * (1 - l_discount)) as sum_disc_price, sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge, avg(l_quantity) as avg_qty, avg(l_extendedprice) as avg_price, avg(l_discount) as avg_disc, count(*) as count_order from lineitem where l_shipdate <= dateadd(dd, -1 * ?, cast('1998-12-01' as datetime)) group by l_returnflag, l_linestatus order by l_returnflag, l_linestatus - select TOP 100 - s_acctbal, - s_name, - n_name, - p_partkey, - p_mfgr, - s_address, - s_phone, - s_comment - from - part, - supplier, - partsupp, - nation, - region - where - p_partkey = ps_partkey - and s_suppkey = ps_suppkey - and p_size = ? - and p_type like ? - and s_nationkey = n_nationkey - and n_regionkey = r_regionkey - and r_name = ? - and ps_supplycost = ( - select - min(ps_supplycost) - from - partsupp, - supplier, - nation, - region - where - p_partkey = ps_partkey - and s_suppkey = ps_suppkey - and s_nationkey = n_nationkey - and n_regionkey = r_regionkey - and r_name = ? - ) - order by - s_acctbal desc, - n_name, - s_name, - p_partkey + select top 100 s_acctbal, s_name, n_name, p_partkey, p_mfgr, s_address, s_phone, s_comment from part, supplier, partsupp, nation, region where p_partkey = ps_partkey and s_suppkey = ps_suppkey and p_size = ? and p_type like ? and s_nationkey = n_nationkey and n_regionkey = r_regionkey and r_name = ? and ps_supplycost = ( select min(ps_supplycost) from partsupp, supplier, nation, region where p_partkey = ps_partkey and s_suppkey = ps_suppkey and s_nationkey = n_nationkey and n_regionkey = r_regionkey and r_name = ? ) order by s_acctbal desc, n_name, s_name, p_partkey - select TOP 10 - l_orderkey, - sum(l_extendedprice * (1 - l_discount)) as revenue, - o_orderdate, - o_shippriority - from - customer, - orders, - lineitem - where - c_mktsegment = ? - and c_custkey = o_custkey - and l_orderkey = o_orderkey - and o_orderdate < ? - and l_shipdate > ? - group by - l_orderkey, - o_orderdate, - o_shippriority - order by - revenue desc, - o_orderdate + select top 10 l_orderkey, sum(l_extendedprice * (1 - l_discount)) as revenue, o_orderdate, o_shippriority from customer, orders, lineitem where c_mktsegment = ? and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < ? and l_shipdate > ? group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate - select - o_orderpriority, - count(*) as order_count - from - orders - where - o_orderdate >= ? - and o_orderdate < dateadd(mm, 3, cast(? as datetime)) - and exists ( - select - * - from - lineitem - where - l_orderkey = o_orderkey - and l_commitdate < l_receiptdate - ) - group by - o_orderpriority - order by - o_orderpriority + select o_orderpriority, count(*) as order_count from orders where o_orderdate >= ? and o_orderdate < dateadd(mm, 3, cast(? as datetime)) and exists ( select * from lineitem where l_orderkey = o_orderkey and l_commitdate < l_receiptdate ) group by o_orderpriority order by o_orderpriority - select - n_name, - sum(l_extendedprice * (1 - l_discount)) as revenue - from - customer, - orders, - lineitem, - supplier, - nation, - region - where - c_custkey = o_custkey - and l_orderkey = o_orderkey - and l_suppkey = s_suppkey - and c_nationkey = s_nationkey - and s_nationkey = n_nationkey - and n_regionkey = r_regionkey - and r_name = ? - and o_orderdate >= ? - and o_orderdate < dateadd(YY, 1, cast(? as datetime)) - group by - n_name - order by - revenue desc + select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue from customer, orders, lineitem, supplier, nation, region where c_custkey = o_custkey and l_orderkey = o_orderkey and l_suppkey = s_suppkey and c_nationkey = s_nationkey and s_nationkey = n_nationkey and n_regionkey = r_regionkey and r_name = ? and o_orderdate >= ? and o_orderdate < dateadd(YY, 1, cast(? as datetime)) group by n_name order by revenue desc - select - sum(l_extendedprice * l_discount) as revenue - from - lineitem - where - l_shipdate >= ? - and l_shipdate < dateadd(yy, 1, cast(? as datetime)) - and l_discount between ? - 0.01 and ? + 0.01 - and l_quantity < ? + select sum(l_extendedprice * l_discount) as revenue from lineitem where l_shipdate >= ? and l_shipdate < dateadd(yy, 1, cast(? as datetime)) and l_discount between ? - 0.01 and ? + 0.01 and l_quantity < ? - select - supp_nation, - cust_nation, - l_year, - sum(volume) as revenue - from - ( - select - n1.n_name as supp_nation, - n2.n_name as cust_nation, - datepart(yy, l_shipdate) as l_year, - l_extendedprice * (1 - l_discount) as volume - from - supplier, - lineitem, - orders, - customer, - nation n1, - nation n2 - where - s_suppkey = l_suppkey - and o_orderkey = l_orderkey - and c_custkey = o_custkey - and s_nationkey = n1.n_nationkey - and c_nationkey = n2.n_nationkey - and ( - (n1.n_name = ? and n2.n_name = ?) - or (n1.n_name = ? and n2.n_name = ?) - ) - and l_shipdate between '1995-01-01' and '1996-12-31' - ) as shipping - group by - supp_nation, - cust_nation, - l_year - order by - supp_nation, - cust_nation, - l_year + select supp_nation, cust_nation, l_year, sum(volume) as revenue from ( select n1.n_name as supp_nation, n2.n_name as cust_nation, datepart(yy, l_shipdate) as l_year, l_extendedprice * (1 - l_discount) as volume from supplier, lineitem, orders, customer, nation n1, nation n2 where s_suppkey = l_suppkey and o_orderkey = l_orderkey and c_custkey = o_custkey and s_nationkey = n1.n_nationkey and c_nationkey = n2.n_nationkey and ( (n1.n_name = ? and n2.n_name = ?) or (n1.n_name = ? and n2.n_name = ?) ) and l_shipdate between '1995-01-01' and '1996-12-31' ) as shipping group by supp_nation, cust_nation, l_year order by supp_nation, cust_nation, l_year - select - o_year, - sum(case - when nation = ? then volume - else 0 - end) / sum(volume) as mkt_share - from - ( - select - datepart(yy,o_orderdate) as o_year, - l_extendedprice * (1 - l_discount) as volume, - n2.n_name as nation - from - part, - supplier, - lineitem, - orders, - customer, - nation n1, - nation n2, - region - where - p_partkey = l_partkey - and s_suppkey = l_suppkey - and l_orderkey = o_orderkey - and o_custkey = c_custkey - and c_nationkey = n1.n_nationkey - and n1.n_regionkey = r_regionkey - and r_name = ? - and s_nationkey = n2.n_nationkey - and o_orderdate between '1995-01-01' and '1996-12-31' - and p_type = ? - ) as all_nations - group by - o_year - order by - o_year + select o_year, sum(case when nation = ? then volume else 0 end) / sum(volume) as mkt_share from ( select datepart(yy,o_orderdate) as o_year, l_extendedprice * (1 - l_discount) as volume, n2.n_name as nation from part, supplier, lineitem, orders, customer, nation n1, nation n2, region where p_partkey = l_partkey and s_suppkey = l_suppkey and l_orderkey = o_orderkey and o_custkey = c_custkey and c_nationkey = n1.n_nationkey and n1.n_regionkey = r_regionkey and r_name = ? and s_nationkey = n2.n_nationkey and o_orderdate between '1995-01-01' and '1996-12-31' and p_type = ? ) as all_nations group by o_year order by o_year - select - nation, - o_year, - sum(amount) as sum_profit - from - ( - select - n_name as nation, - datepart(yy, o_orderdate) as o_year, - l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount - from - part, - supplier, - lineitem, - partsupp, - orders, - nation - where - s_suppkey = l_suppkey - and ps_suppkey = l_suppkey - and ps_partkey = l_partkey - and p_partkey = l_partkey - and o_orderkey = l_orderkey - and s_nationkey = n_nationkey - and p_name like ? - ) as profit - group by - nation, - o_year - order by - nation, - o_year desc + select nation, o_year, sum(amount) as sum_profit from ( select n_name as nation, datepart(yy, o_orderdate) as o_year, l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount from part, supplier, lineitem, partsupp, orders, nation where s_suppkey = l_suppkey and ps_suppkey = l_suppkey and ps_partkey = l_partkey and p_partkey = l_partkey and o_orderkey = l_orderkey and s_nationkey = n_nationkey and p_name like ? ) as profit group by nation, o_year order by nation, o_year desc - select TOP 20 - c_custkey, - c_name, - sum(l_extendedprice * (1 - l_discount)) as revenue, - c_acctbal, - n_name, - c_address, - c_phone, - c_comment - from - customer, - orders, - lineitem, - nation - where - c_custkey = o_custkey - and l_orderkey = o_orderkey - and o_orderdate >= ? - and o_orderdate < dateadd(mm, 3, cast(? as datetime)) - and l_returnflag = 'R' - and c_nationkey = n_nationkey - group by - c_custkey, - c_name, - c_acctbal, - c_phone, - n_name, - c_address, - c_comment - order by - revenue desc + select top 20 c_custkey, c_name, sum(l_extendedprice * (1 - l_discount)) as revenue, c_acctbal, n_name, c_address, c_phone, c_comment from customer, orders, lineitem, nation where c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate >= ? and o_orderdate < dateadd(mm, 3, cast(? as datetime)) and l_returnflag = 'R' and c_nationkey = n_nationkey group by c_custkey, c_name, c_acctbal, c_phone, n_name, c_address, c_comment order by revenue desc - select - l_shipmode, - sum(case - when o_orderpriority = '1-URGENT' - or o_orderpriority = '2-HIGH' - then 1 - else 0 - end) as high_line_count, - sum(case - when o_orderpriority <> '1-URGENT' - and o_orderpriority <> '2-HIGH' - then 1 - else 0 - end) as low_line_count - from - orders, - lineitem - where - o_orderkey = l_orderkey - and l_shipmode in (?, ?) - and l_commitdate < l_receiptdate - and l_shipdate < l_commitdate - and l_receiptdate >= ? - and l_receiptdate < dateadd(mm, 1, cast(? as datetime)) - group by - l_shipmode - order by - l_shipmode + select l_shipmode, sum(case when o_orderpriority = '1-URGENT' or o_orderpriority = '2-HIGH' then 1 else 0 end) as high_line_count, sum(case when o_orderpriority <> '1-URGENT' and o_orderpriority <> '2-HIGH' then 1 else 0 end) as low_line_count from orders, lineitem where o_orderkey = l_orderkey and l_shipmode in (?, ?) and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= ? and l_receiptdate < dateadd(mm, 1, cast(? as datetime)) group by l_shipmode order by l_shipmode - select - 100.00 * sum(case - when p_type like 'PROMO%' - then l_extendedprice * (1 - l_discount) - else 0 - end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue - from - lineitem, - part - where - l_partkey = p_partkey - and l_shipdate >= ? - and l_shipdate < dateadd(mm, 1, cast(? as datetime)) + select 100.00 * sum(case when p_type like 'PROMO%' then l_extendedprice * (1 - l_discount) else 0 end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue from lineitem, part where l_partkey = p_partkey and l_shipdate >= ? and l_shipdate < dateadd(mm, 1, cast(? as datetime)) - create view revenue0 (supplier_no, total_revenue) as - select - l_suppkey, - sum(l_extendedprice * (1 - l_discount)) - from - lineitem - where - l_shipdate >= ? - and l_shipdate < dateadd(mm, 3, cast(? as datetime)) - group by - l_suppkey + create view revenue0 (supplier_no, total_revenue) as select l_suppkey, sum(l_extendedprice * (1 - l_discount)) from lineitem where l_shipdate >= ? and l_shipdate < dateadd(mm, 3, cast(? as datetime)) group by l_suppkey - select TOP 100 - c_name, - c_custkey, - o_orderkey, - o_orderdate, - o_totalprice, - sum(l_quantity) - from - customer, - orders, - lineitem - where - o_orderkey in ( - select - l_orderkey - from - lineitem - group by - l_orderkey having - sum(l_quantity) > ? - ) - and c_custkey = o_custkey - and o_orderkey = l_orderkey - group by - c_name, - c_custkey, - o_orderkey, - o_orderdate, - o_totalprice - order by - o_totalprice desc, - o_orderdate + select top 100 c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, sum(l_quantity) from customer, orders, lineitem where o_orderkey in ( select l_orderkey from lineitem group by l_orderkey having sum(l_quantity) > ? ) and c_custkey = o_custkey and o_orderkey = l_orderkey group by c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice order by o_totalprice desc, o_orderdate - select - s_name, - s_address - from - supplier, - nation - where - s_suppkey in ( - select - ps_suppkey - from - partsupp - where - ps_partkey in ( - select - p_partkey - from - part - where - p_name like ? - ) - and ps_availqty > ( - select - 0.5 * sum(l_quantity) - from - lineitem - where - l_partkey = ps_partkey - and l_suppkey = ps_suppkey - and l_shipdate >= ? - and l_shipdate < dateadd(yy, 1, cast(? as datetime)) - ) - ) - and s_nationkey = n_nationkey - and n_name = ? - order by - s_name + select s_name, s_address from supplier, nation where s_suppkey in ( select ps_suppkey from partsupp where ps_partkey in ( select p_partkey from part where p_name like ? ) and ps_availqty > ( select 0.5 * sum(l_quantity) from lineitem where l_partkey = ps_partkey and l_suppkey = ps_suppkey and l_shipdate >= ? and l_shipdate < dateadd(yy, 1, cast(? as datetime)) ) ) and s_nationkey = n_nationkey and n_name = ? order by s_name - select TOP 100 - s_name, - count(*) as numwait - from - supplier, - lineitem l1, - orders, - nation - where - s_suppkey = l1.l_suppkey - and o_orderkey = l1.l_orderkey - and o_orderstatus = 'F' - and l1.l_receiptdate > l1.l_commitdate - and exists ( - select - * - from - lineitem l2 - where - l2.l_orderkey = l1.l_orderkey - and l2.l_suppkey <> l1.l_suppkey - ) - and not exists ( - select - * - from - lineitem l3 - where - l3.l_orderkey = l1.l_orderkey - and l3.l_suppkey <> l1.l_suppkey - and l3.l_receiptdate > l3.l_commitdate - ) - and s_nationkey = n_nationkey - and n_name = ? - group by - s_name - order by - numwait desc, - s_name + select top 100 s_name, count(*) as numwait from supplier, lineitem l1, orders, nation where s_suppkey = l1.l_suppkey and o_orderkey = l1.l_orderkey and o_orderstatus = 'F' and l1.l_receiptdate > l1.l_commitdate and exists ( select * from lineitem l2 where l2.l_orderkey = l1.l_orderkey and l2.l_suppkey <> l1.l_suppkey ) and not exists ( select * from lineitem l3 where l3.l_orderkey = l1.l_orderkey and l3.l_suppkey <> l1.l_suppkey and l3.l_receiptdate > l3.l_commitdate ) and s_nationkey = n_nationkey and n_name = ? group by s_name order by numwait desc, s_name - select - cntrycode, - count(*) as numcust, - sum(c_acctbal) as totacctbal - from - ( - select - substring(c_phone, 1, 2) as cntrycode, - c_acctbal - from - customer - where - substring(c_phone, 1, 2) in - (?, ?, ?, ?, ?, ?, ?) - and c_acctbal > ( - select - avg(c_acctbal) - from - customer - where - c_acctbal > 0.00 - and substring(c_phone, 1, 2) in - (?, ?, ?, ?, ?, ?, ?) - ) - and not exists ( - select - * - from - orders - where - o_custkey = c_custkey - ) - ) as custsale - group by - cntrycode - order by - cntrycode + select cntrycode, count(*) as numcust, sum(c_acctbal) as totacctbal from ( select substring(c_phone, 1, 2) as cntrycode, c_acctbal from customer where substring(c_phone, 1, 2) in (?, ?, ?, ?, ?, ?, ?) and c_acctbal > ( select avg(c_acctbal) from customer where c_acctbal > 0.00 and substring(c_phone, 1, 2) in (?, ?, ?, ?, ?, ?, ?) ) and not exists ( select * from orders where o_custkey = c_custkey ) ) as custsale group by cntrycode order by cntrycode From a2b505f75963cdb1a4724c7f38a378a705d7e995 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 15 Apr 2022 15:12:45 -0500 Subject: [PATCH 3/9] Adding tests for MSSQL in Github actions (TPC-C and TPC-H) * Adds Github Actions CI support via the SqlServer Docker image. * Adds other docker run support. * Adds a column store based schema creation command in addition to the row store one, and a symlink to chose between them (defaulting to cstore). --- .github/workflows/maven.yml | 65 +++++++- config/sqlserver/sample_tpcc_config.xml | 54 +++++++ config/sqlserver/sample_tpch_config.xml | 6 +- .../sqlserver-2019-latest/docker-compose.yml | 16 ++ docker/sqlserver-2019-latest/down.sh | 3 + docker/sqlserver-2019-latest/prune.sh | 3 + docker/sqlserver-2019-latest/up.sh | 3 + .../benchmarks/tpch/ddl-sqlserver.cstore.sql | 141 ++++++++++++++++++ .../benchmarks/tpch/ddl-sqlserver.rstore.sql | 133 +++++++++++++++++ .../benchmarks/tpch/ddl-sqlserver.sql | 134 +---------------- 10 files changed, 421 insertions(+), 137 deletions(-) create mode 100644 config/sqlserver/sample_tpcc_config.xml create mode 100644 docker/sqlserver-2019-latest/docker-compose.yml create mode 100755 docker/sqlserver-2019-latest/down.sh create mode 100755 docker/sqlserver-2019-latest/prune.sh create mode 100755 docker/sqlserver-2019-latest/up.sh create mode 100644 src/main/resources/benchmarks/tpch/ddl-sqlserver.cstore.sql create mode 100644 src/main/resources/benchmarks/tpch/ddl-sqlserver.rstore.sql mode change 100644 => 120000 src/main/resources/benchmarks/tpch/ddl-sqlserver.sql diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 73c0e450a..d29cfd66e 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -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 @@ -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 diff --git a/config/sqlserver/sample_tpcc_config.xml b/config/sqlserver/sample_tpcc_config.xml new file mode 100644 index 000000000..a19d975d1 --- /dev/null +++ b/config/sqlserver/sample_tpcc_config.xml @@ -0,0 +1,54 @@ + + + + + sqlserver + com.microsoft.sqlserver.jdbc.SQLServerDriver + jdbc:sqlserver://localhost:1433;encrypt=false;database=benchbase_tpcc; + benchuser01 + P@ssw0rd + TRANSACTION_SERIALIZABLE + 128 + + + 1 + + + 1 + + + + 10000 + 45,43,4,4,4 + + + + + + + NewOrder + + + + + Payment + + + + + OrderStatus + + + + + Delivery + + + + + StockLevel + + + + + diff --git a/config/sqlserver/sample_tpch_config.xml b/config/sqlserver/sample_tpch_config.xml index 546cd842b..078aad778 100644 --- a/config/sqlserver/sample_tpch_config.xml +++ b/config/sqlserver/sample_tpch_config.xml @@ -2,13 +2,13 @@ - SQLSERVER + sqlserver com.microsoft.sqlserver.jdbc.SQLServerDriver - jdbc:sqlserver://localhost:1433;encrypt=false; + jdbc:sqlserver://localhost:1433;encrypt=false;database=benchbase_tpch; benchuser01 P@ssw0rd TRANSACTION_SERIALIZABLE - 128 + 1024 0.1 diff --git a/docker/sqlserver-2019-latest/docker-compose.yml b/docker/sqlserver-2019-latest/docker-compose.yml new file mode 100644 index 000000000..3b2f0c33e --- /dev/null +++ b/docker/sqlserver-2019-latest/docker-compose.yml @@ -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 diff --git a/docker/sqlserver-2019-latest/down.sh b/docker/sqlserver-2019-latest/down.sh new file mode 100755 index 000000000..6215909ac --- /dev/null +++ b/docker/sqlserver-2019-latest/down.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker compose down --remove-orphans --volumes \ No newline at end of file diff --git a/docker/sqlserver-2019-latest/prune.sh b/docker/sqlserver-2019-latest/prune.sh new file mode 100755 index 000000000..d1daed3e2 --- /dev/null +++ b/docker/sqlserver-2019-latest/prune.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker system prune -a -f --volumes \ No newline at end of file diff --git a/docker/sqlserver-2019-latest/up.sh b/docker/sqlserver-2019-latest/up.sh new file mode 100755 index 000000000..d4d791afc --- /dev/null +++ b/docker/sqlserver-2019-latest/up.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker compose up -d \ No newline at end of file diff --git a/src/main/resources/benchmarks/tpch/ddl-sqlserver.cstore.sql b/src/main/resources/benchmarks/tpch/ddl-sqlserver.cstore.sql new file mode 100644 index 000000000..67244c170 --- /dev/null +++ b/src/main/resources/benchmarks/tpch/ddl-sqlserver.cstore.sql @@ -0,0 +1,141 @@ +-- Adapted from the Postgres schema +DROP TABLE IF EXISTS lineitem; +DROP TABLE IF EXISTS orders; +DROP TABLE IF EXISTS customer; +DROP TABLE IF EXISTS partsupp; +DROP TABLE IF EXISTS part; +DROP TABLE IF EXISTS supplier; +DROP TABLE IF EXISTS nation; +DROP TABLE IF EXISTS region; + +CREATE TABLE region ( + r_regionkey integer NOT NULL, + r_name char(25) NOT NULL, + r_comment varchar(152), + INDEX region_cstore CLUSTERED COLUMNSTORE, + -- PRIMARY KEY (r_regionkey), + INDEX r_rk UNIQUE (r_regionkey ASC), +); + +CREATE TABLE nation ( + n_nationkey integer NOT NULL, + n_name char(25) NOT NULL, + n_regionkey integer NOT NULL, + n_comment varchar(152), + INDEX nation_cstore CLUSTERED COLUMNSTORE, + -- PRIMARY KEY (n_nationkey), + INDEX n_nk UNIQUE (n_nationkey ASC), + INDEX n_rk (n_regionkey ASC), + FOREIGN KEY (n_regionkey) REFERENCES region (r_regionkey) +); + +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, + INDEX part_cstore CLUSTERED COLUMNSTORE, + -- PRIMARY KEY (p_partkey) + INDEX p_pk UNIQUE (p_partkey ASC) +); + +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, + INDEX supplier_cstore CLUSTERED COLUMNSTORE, + -- PRIMARY KEY (s_suppkey), + INDEX s_sk UNIQUE (s_suppkey ASC), + INDEX s_nk (s_nationkey ASC), + FOREIGN KEY (s_nationkey) REFERENCES nation (n_nationkey) +); + +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, + INDEX partsupp_cstore CLUSTERED COLUMNSTORE, + -- PRIMARY KEY (ps_partkey, ps_suppkey), + INDEX ps_pk (ps_partkey ASC), + INDEX ps_sk (ps_suppkey ASC), + INDEX ps_pk_sk UNIQUE (ps_partkey ASC, ps_suppkey ASC), + INDEX ps_sk_pk UNIQUE (ps_suppkey ASC, ps_partkey ASC), + FOREIGN KEY (ps_partkey) REFERENCES part (p_partkey), + FOREIGN KEY (ps_suppkey) REFERENCES supplier (s_suppkey) +); + +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, + INDEX customer_cstore CLUSTERED COLUMNSTORE, + -- PRIMARY KEY (c_custkey), + INDEX c_ck UNIQUE (c_custkey ASC), + INDEX c_nk (c_nationkey ASC), + FOREIGN KEY (c_nationkey) REFERENCES nation (n_nationkey) +); + +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, + INDEX o_orderdate_idx CLUSTERED COLUMNSTORE, + -- PRIMARY KEY (o_orderkey), + INDEX o_ok UNIQUE (o_orderkey ASC), + INDEX o_ck (o_custkey ASC), + INDEX o_od (o_orderdate ASC), + FOREIGN KEY (o_custkey) REFERENCES customer (c_custkey) +); + +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, + INDEX l_shipdate_idx CLUSTERED COLUMNSTORE, + -- PRIMARY KEY (l_orderkey, l_linenumber), + INDEX l_ok (l_orderkey ASC), + INDEX l_pk (l_partkey ASC), + INDEX l_sk (l_suppkey ASC), + INDEX l_sd (l_shipdate ASC), + INDEX l_cd (l_commitdate ASC), + INDEX l_rd (l_receiptdate ASC), + INDEX l_pk_sk (l_partkey ASC, l_suppkey ASC), + INDEX l_sk_pk (l_suppkey ASC, l_partkey ASC), + FOREIGN KEY (l_orderkey) REFERENCES orders (o_orderkey), + FOREIGN KEY (l_partkey, l_suppkey) REFERENCES partsupp (ps_partkey, ps_suppkey) +); diff --git a/src/main/resources/benchmarks/tpch/ddl-sqlserver.rstore.sql b/src/main/resources/benchmarks/tpch/ddl-sqlserver.rstore.sql new file mode 100644 index 000000000..af09237bb --- /dev/null +++ b/src/main/resources/benchmarks/tpch/ddl-sqlserver.rstore.sql @@ -0,0 +1,133 @@ +-- Adapted from the Postgres schema +DROP TABLE IF EXISTS lineitem; +DROP TABLE IF EXISTS orders; +DROP TABLE IF EXISTS customer; +DROP TABLE IF EXISTS partsupp; +DROP TABLE IF EXISTS part; +DROP TABLE IF EXISTS supplier; +DROP TABLE IF EXISTS nation; +DROP TABLE IF EXISTS region; + +CREATE TABLE region ( + r_regionkey integer NOT NULL, + r_name char(25) NOT NULL, + r_comment varchar(152), + PRIMARY KEY (r_regionkey), + INDEX r_rk UNIQUE (r_regionkey ASC), +); + +CREATE TABLE nation ( + n_nationkey integer NOT NULL, + n_name char(25) NOT NULL, + n_regionkey integer NOT NULL, + n_comment varchar(152), + PRIMARY KEY (n_nationkey), + INDEX n_nk UNIQUE (n_nationkey ASC), + INDEX n_rk (n_regionkey ASC), + FOREIGN KEY (n_regionkey) REFERENCES region (r_regionkey) +); + +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, + PRIMARY KEY (p_partkey), + INDEX p_pk UNIQUE (p_partkey ASC) +); + +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, + PRIMARY KEY (s_suppkey), + INDEX s_sk UNIQUE (s_suppkey ASC), + INDEX s_nk (s_nationkey ASC), + FOREIGN KEY (s_nationkey) REFERENCES nation (n_nationkey) +); + +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, + PRIMARY KEY (ps_partkey, ps_suppkey), + INDEX ps_pk (ps_partkey ASC), + INDEX ps_sk (ps_suppkey ASC), + INDEX ps_pk_sk UNIQUE (ps_partkey ASC, ps_suppkey ASC), + INDEX ps_sk_pk UNIQUE (ps_suppkey ASC, ps_partkey ASC), + FOREIGN KEY (ps_partkey) REFERENCES part (p_partkey), + FOREIGN KEY (ps_suppkey) REFERENCES supplier (s_suppkey) +); + +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, + PRIMARY KEY (c_custkey), + INDEX c_ck UNIQUE (c_custkey ASC), + INDEX c_nk (c_nationkey ASC), + FOREIGN KEY (c_nationkey) REFERENCES nation (n_nationkey) +); + +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, + PRIMARY KEY (o_orderkey), + INDEX o_ok UNIQUE (o_orderkey ASC), + INDEX o_ck (o_custkey ASC), + INDEX o_od (o_orderdate ASC), + FOREIGN KEY (o_custkey) REFERENCES customer (c_custkey) +); + +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, + PRIMARY KEY (l_orderkey, l_linenumber), + INDEX l_ok (l_orderkey ASC), + INDEX l_pk (l_partkey ASC), + INDEX l_sk (l_suppkey ASC), + INDEX l_sd (l_shipdate ASC), + INDEX l_cd (l_commitdate ASC), + INDEX l_rd (l_receiptdate ASC), + INDEX l_pk_sk (l_partkey ASC, l_suppkey ASC), + INDEX l_sk_pk (l_suppkey ASC, l_partkey ASC), + FOREIGN KEY (l_orderkey) REFERENCES orders (o_orderkey), + FOREIGN KEY (l_partkey, l_suppkey) REFERENCES partsupp (ps_partkey, ps_suppkey) +); diff --git a/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql b/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql deleted file mode 100644 index 1d68c84c3..000000000 --- a/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql +++ /dev/null @@ -1,133 +0,0 @@ --- Adapted from the Postgres schema -DROP TABLE IF EXISTS lineitem; -DROP TABLE IF EXISTS orders; -DROP TABLE IF EXISTS customer; -DROP TABLE IF EXISTS partsupp; -DROP TABLE IF EXISTS part; -DROP TABLE IF EXISTS supplier; -DROP TABLE IF EXISTS nation; -DROP TABLE IF EXISTS region; - -CREATE TABLE region ( - r_regionkey integer NOT NULL, - r_name char(25) NOT NULL, - r_comment varchar(152), - PRIMARY KEY (r_regionkey) -); -CREATE UNIQUE INDEX r_rk ON region (r_regionkey ASC); - -CREATE TABLE nation ( - n_nationkey integer NOT NULL, - n_name char(25) NOT NULL, - n_regionkey integer NOT NULL, - n_comment varchar(152), - PRIMARY KEY (n_nationkey), - FOREIGN KEY (n_regionkey) REFERENCES region (r_regionkey) -); -CREATE UNIQUE INDEX n_nk ON nation (n_nationkey ASC); -CREATE INDEX n_rk ON nation (n_regionkey ASC); - -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, - PRIMARY KEY (p_partkey) -); -CREATE UNIQUE INDEX p_pk ON part (p_partkey ASC); - -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, - PRIMARY KEY (s_suppkey), - FOREIGN KEY (s_nationkey) REFERENCES nation (n_nationkey) -); -CREATE UNIQUE INDEX s_sk ON supplier (s_suppkey ASC); -CREATE INDEX s_nk ON supplier (s_nationkey ASC); - -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, - PRIMARY KEY (ps_partkey, ps_suppkey), - FOREIGN KEY (ps_partkey) REFERENCES part (p_partkey), - FOREIGN KEY (ps_suppkey) REFERENCES supplier (s_suppkey) -); -CREATE INDEX ps_pk ON partsupp (ps_partkey ASC); -CREATE INDEX ps_sk ON partsupp (ps_suppkey ASC); -CREATE UNIQUE INDEX ps_pk_sk ON partsupp (ps_partkey ASC, ps_suppkey ASC); -CREATE UNIQUE INDEX ps_sk_pk ON partsupp (ps_suppkey ASC, ps_partkey ASC); - -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, - PRIMARY KEY (c_custkey), - FOREIGN KEY (c_nationkey) REFERENCES nation (n_nationkey) -); -CREATE UNIQUE INDEX c_ck ON customer (c_custkey ASC); -CREATE INDEX c_nk ON customer (c_nationkey ASC); - -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, - PRIMARY KEY (o_orderkey), - FOREIGN KEY (o_custkey) REFERENCES customer (c_custkey) -); -CREATE UNIQUE INDEX o_ok ON orders (o_orderkey ASC); -CREATE INDEX o_ck ON orders (o_custkey ASC); -CREATE INDEX o_od ON orders (o_orderdate ASC); - -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, - PRIMARY KEY (l_orderkey, l_linenumber), - FOREIGN KEY (l_orderkey) REFERENCES orders (o_orderkey), - FOREIGN KEY (l_partkey, l_suppkey) REFERENCES partsupp (ps_partkey, ps_suppkey) -); -CREATE INDEX l_ok ON lineitem (l_orderkey ASC); -CREATE INDEX l_pk ON lineitem (l_partkey ASC); -CREATE INDEX l_sk ON lineitem (l_suppkey ASC); -CREATE INDEX l_sd ON lineitem (l_shipdate ASC); -CREATE INDEX l_cd ON lineitem (l_commitdate ASC); -CREATE INDEX l_rd ON lineitem (l_receiptdate ASC); -CREATE INDEX l_pk_sk ON lineitem (l_partkey ASC, l_suppkey ASC); -CREATE INDEX l_sk_pk ON lineitem (l_suppkey ASC, l_partkey ASC); diff --git a/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql b/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql new file mode 120000 index 000000000..ae1555f9f --- /dev/null +++ b/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql @@ -0,0 +1 @@ +ddl-sqlserver.cstore.sql \ No newline at end of file From 8b1d836a1510f173552892ad85dd85b619a966f2 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Wed, 20 Apr 2022 10:45:12 -0500 Subject: [PATCH 4/9] addressing comments in See --- .../benchmarks/tpch/ddl-sqlserver.cstore.sql | 141 ----------------- .../benchmarks/tpch/ddl-sqlserver.rstore.sql | 133 ---------------- .../benchmarks/tpch/ddl-sqlserver.sql | 146 +++++++++++++++++- 3 files changed, 145 insertions(+), 275 deletions(-) delete mode 100644 src/main/resources/benchmarks/tpch/ddl-sqlserver.cstore.sql delete mode 100644 src/main/resources/benchmarks/tpch/ddl-sqlserver.rstore.sql mode change 120000 => 100644 src/main/resources/benchmarks/tpch/ddl-sqlserver.sql diff --git a/src/main/resources/benchmarks/tpch/ddl-sqlserver.cstore.sql b/src/main/resources/benchmarks/tpch/ddl-sqlserver.cstore.sql deleted file mode 100644 index 67244c170..000000000 --- a/src/main/resources/benchmarks/tpch/ddl-sqlserver.cstore.sql +++ /dev/null @@ -1,141 +0,0 @@ --- Adapted from the Postgres schema -DROP TABLE IF EXISTS lineitem; -DROP TABLE IF EXISTS orders; -DROP TABLE IF EXISTS customer; -DROP TABLE IF EXISTS partsupp; -DROP TABLE IF EXISTS part; -DROP TABLE IF EXISTS supplier; -DROP TABLE IF EXISTS nation; -DROP TABLE IF EXISTS region; - -CREATE TABLE region ( - r_regionkey integer NOT NULL, - r_name char(25) NOT NULL, - r_comment varchar(152), - INDEX region_cstore CLUSTERED COLUMNSTORE, - -- PRIMARY KEY (r_regionkey), - INDEX r_rk UNIQUE (r_regionkey ASC), -); - -CREATE TABLE nation ( - n_nationkey integer NOT NULL, - n_name char(25) NOT NULL, - n_regionkey integer NOT NULL, - n_comment varchar(152), - INDEX nation_cstore CLUSTERED COLUMNSTORE, - -- PRIMARY KEY (n_nationkey), - INDEX n_nk UNIQUE (n_nationkey ASC), - INDEX n_rk (n_regionkey ASC), - FOREIGN KEY (n_regionkey) REFERENCES region (r_regionkey) -); - -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, - INDEX part_cstore CLUSTERED COLUMNSTORE, - -- PRIMARY KEY (p_partkey) - INDEX p_pk UNIQUE (p_partkey ASC) -); - -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, - INDEX supplier_cstore CLUSTERED COLUMNSTORE, - -- PRIMARY KEY (s_suppkey), - INDEX s_sk UNIQUE (s_suppkey ASC), - INDEX s_nk (s_nationkey ASC), - FOREIGN KEY (s_nationkey) REFERENCES nation (n_nationkey) -); - -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, - INDEX partsupp_cstore CLUSTERED COLUMNSTORE, - -- PRIMARY KEY (ps_partkey, ps_suppkey), - INDEX ps_pk (ps_partkey ASC), - INDEX ps_sk (ps_suppkey ASC), - INDEX ps_pk_sk UNIQUE (ps_partkey ASC, ps_suppkey ASC), - INDEX ps_sk_pk UNIQUE (ps_suppkey ASC, ps_partkey ASC), - FOREIGN KEY (ps_partkey) REFERENCES part (p_partkey), - FOREIGN KEY (ps_suppkey) REFERENCES supplier (s_suppkey) -); - -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, - INDEX customer_cstore CLUSTERED COLUMNSTORE, - -- PRIMARY KEY (c_custkey), - INDEX c_ck UNIQUE (c_custkey ASC), - INDEX c_nk (c_nationkey ASC), - FOREIGN KEY (c_nationkey) REFERENCES nation (n_nationkey) -); - -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, - INDEX o_orderdate_idx CLUSTERED COLUMNSTORE, - -- PRIMARY KEY (o_orderkey), - INDEX o_ok UNIQUE (o_orderkey ASC), - INDEX o_ck (o_custkey ASC), - INDEX o_od (o_orderdate ASC), - FOREIGN KEY (o_custkey) REFERENCES customer (c_custkey) -); - -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, - INDEX l_shipdate_idx CLUSTERED COLUMNSTORE, - -- PRIMARY KEY (l_orderkey, l_linenumber), - INDEX l_ok (l_orderkey ASC), - INDEX l_pk (l_partkey ASC), - INDEX l_sk (l_suppkey ASC), - INDEX l_sd (l_shipdate ASC), - INDEX l_cd (l_commitdate ASC), - INDEX l_rd (l_receiptdate ASC), - INDEX l_pk_sk (l_partkey ASC, l_suppkey ASC), - INDEX l_sk_pk (l_suppkey ASC, l_partkey ASC), - FOREIGN KEY (l_orderkey) REFERENCES orders (o_orderkey), - FOREIGN KEY (l_partkey, l_suppkey) REFERENCES partsupp (ps_partkey, ps_suppkey) -); diff --git a/src/main/resources/benchmarks/tpch/ddl-sqlserver.rstore.sql b/src/main/resources/benchmarks/tpch/ddl-sqlserver.rstore.sql deleted file mode 100644 index af09237bb..000000000 --- a/src/main/resources/benchmarks/tpch/ddl-sqlserver.rstore.sql +++ /dev/null @@ -1,133 +0,0 @@ --- Adapted from the Postgres schema -DROP TABLE IF EXISTS lineitem; -DROP TABLE IF EXISTS orders; -DROP TABLE IF EXISTS customer; -DROP TABLE IF EXISTS partsupp; -DROP TABLE IF EXISTS part; -DROP TABLE IF EXISTS supplier; -DROP TABLE IF EXISTS nation; -DROP TABLE IF EXISTS region; - -CREATE TABLE region ( - r_regionkey integer NOT NULL, - r_name char(25) NOT NULL, - r_comment varchar(152), - PRIMARY KEY (r_regionkey), - INDEX r_rk UNIQUE (r_regionkey ASC), -); - -CREATE TABLE nation ( - n_nationkey integer NOT NULL, - n_name char(25) NOT NULL, - n_regionkey integer NOT NULL, - n_comment varchar(152), - PRIMARY KEY (n_nationkey), - INDEX n_nk UNIQUE (n_nationkey ASC), - INDEX n_rk (n_regionkey ASC), - FOREIGN KEY (n_regionkey) REFERENCES region (r_regionkey) -); - -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, - PRIMARY KEY (p_partkey), - INDEX p_pk UNIQUE (p_partkey ASC) -); - -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, - PRIMARY KEY (s_suppkey), - INDEX s_sk UNIQUE (s_suppkey ASC), - INDEX s_nk (s_nationkey ASC), - FOREIGN KEY (s_nationkey) REFERENCES nation (n_nationkey) -); - -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, - PRIMARY KEY (ps_partkey, ps_suppkey), - INDEX ps_pk (ps_partkey ASC), - INDEX ps_sk (ps_suppkey ASC), - INDEX ps_pk_sk UNIQUE (ps_partkey ASC, ps_suppkey ASC), - INDEX ps_sk_pk UNIQUE (ps_suppkey ASC, ps_partkey ASC), - FOREIGN KEY (ps_partkey) REFERENCES part (p_partkey), - FOREIGN KEY (ps_suppkey) REFERENCES supplier (s_suppkey) -); - -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, - PRIMARY KEY (c_custkey), - INDEX c_ck UNIQUE (c_custkey ASC), - INDEX c_nk (c_nationkey ASC), - FOREIGN KEY (c_nationkey) REFERENCES nation (n_nationkey) -); - -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, - PRIMARY KEY (o_orderkey), - INDEX o_ok UNIQUE (o_orderkey ASC), - INDEX o_ck (o_custkey ASC), - INDEX o_od (o_orderdate ASC), - FOREIGN KEY (o_custkey) REFERENCES customer (c_custkey) -); - -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, - PRIMARY KEY (l_orderkey, l_linenumber), - INDEX l_ok (l_orderkey ASC), - INDEX l_pk (l_partkey ASC), - INDEX l_sk (l_suppkey ASC), - INDEX l_sd (l_shipdate ASC), - INDEX l_cd (l_commitdate ASC), - INDEX l_rd (l_receiptdate ASC), - INDEX l_pk_sk (l_partkey ASC, l_suppkey ASC), - INDEX l_sk_pk (l_suppkey ASC, l_partkey ASC), - FOREIGN KEY (l_orderkey) REFERENCES orders (o_orderkey), - FOREIGN KEY (l_partkey, l_suppkey) REFERENCES partsupp (ps_partkey, ps_suppkey) -); diff --git a/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql b/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql deleted file mode 120000 index ae1555f9f..000000000 --- a/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql +++ /dev/null @@ -1 +0,0 @@ -ddl-sqlserver.cstore.sql \ No newline at end of file diff --git a/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql b/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql new file mode 100644 index 000000000..0b5f7ad26 --- /dev/null +++ b/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql @@ -0,0 +1,145 @@ +-- Adapted from the Postgres schema + +-- Note: To use different storage layouts during --create, +-- switch row/column store commented lines and rebuild. + +DROP TABLE IF EXISTS lineitem; +DROP TABLE IF EXISTS orders; +DROP TABLE IF EXISTS customer; +DROP TABLE IF EXISTS partsupp; +DROP TABLE IF EXISTS part; +DROP TABLE IF EXISTS supplier; +DROP TABLE IF EXISTS nation; +DROP TABLE IF EXISTS region; + +CREATE TABLE region ( + r_regionkey integer NOT NULL, + r_name char(25) NOT NULL, + r_comment varchar(152), + INDEX region_cstore CLUSTERED COLUMNSTORE, -- column store + -- PRIMARY KEY (r_regionkey), -- row store + INDEX r_rk UNIQUE (r_regionkey ASC), +); + +CREATE TABLE nation ( + n_nationkey integer NOT NULL, + n_name char(25) NOT NULL, + n_regionkey integer NOT NULL, + n_comment varchar(152), + INDEX nation_cstore CLUSTERED COLUMNSTORE, -- column store + -- PRIMARY KEY (n_nationkey), -- row store + INDEX n_nk UNIQUE (n_nationkey ASC), + INDEX n_rk (n_regionkey ASC), + FOREIGN KEY (n_regionkey) REFERENCES region (r_regionkey) +); + +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, + INDEX part_cstore CLUSTERED COLUMNSTORE, -- column store + -- PRIMARY KEY (p_partkey), -- row store + INDEX p_pk UNIQUE (p_partkey ASC) +); + +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, + INDEX supplier_cstore CLUSTERED COLUMNSTORE, -- column store + -- PRIMARY KEY (s_suppkey), -- row store + INDEX s_sk UNIQUE (s_suppkey ASC), + INDEX s_nk (s_nationkey ASC), + FOREIGN KEY (s_nationkey) REFERENCES nation (n_nationkey) +); + +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, + INDEX partsupp_cstore CLUSTERED COLUMNSTORE, -- column store + -- PRIMARY KEY (ps_partkey, ps_suppkey), -- row store + INDEX ps_pk (ps_partkey ASC), + INDEX ps_sk (ps_suppkey ASC), + INDEX ps_pk_sk UNIQUE (ps_partkey ASC, ps_suppkey ASC), + INDEX ps_sk_pk UNIQUE (ps_suppkey ASC, ps_partkey ASC), + FOREIGN KEY (ps_partkey) REFERENCES part (p_partkey), + FOREIGN KEY (ps_suppkey) REFERENCES supplier (s_suppkey) +); + +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, + INDEX customer_cstore CLUSTERED COLUMNSTORE, -- column store + -- PRIMARY KEY (c_custkey), -- row store + INDEX c_ck UNIQUE (c_custkey ASC), + INDEX c_nk (c_nationkey ASC), + FOREIGN KEY (c_nationkey) REFERENCES nation (n_nationkey) +); + +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, + INDEX o_orderdate_idx CLUSTERED COLUMNSTORE, -- column store + -- PRIMARY KEY (o_orderkey), -- row store + INDEX o_ok UNIQUE (o_orderkey ASC), + INDEX o_ck (o_custkey ASC), + INDEX o_od (o_orderdate ASC), + FOREIGN KEY (o_custkey) REFERENCES customer (c_custkey) +); + +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, + INDEX l_shipdate_idx CLUSTERED COLUMNSTORE, -- column store + -- PRIMARY KEY (l_orderkey, l_linenumber), -- row store + INDEX l_ok (l_orderkey ASC), + INDEX l_pk (l_partkey ASC), + INDEX l_sk (l_suppkey ASC), + INDEX l_sd (l_shipdate ASC), + INDEX l_cd (l_commitdate ASC), + INDEX l_rd (l_receiptdate ASC), + INDEX l_pk_sk (l_partkey ASC, l_suppkey ASC), + INDEX l_sk_pk (l_suppkey ASC, l_partkey ASC), + FOREIGN KEY (l_orderkey) REFERENCES orders (o_orderkey), + FOREIGN KEY (l_partkey, l_suppkey) REFERENCES partsupp (ps_partkey, ps_suppkey) +); From 7919afc460f0298ee75d538706b637d1b33c85b3 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Wed, 20 Apr 2022 10:52:14 -0500 Subject: [PATCH 5/9] switch to row store by default Also replace some tabs with spaces for consistency --- .../benchmarks/tpch/ddl-sqlserver.sql | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql b/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql index 0b5f7ad26..7e4e59d18 100644 --- a/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql +++ b/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql @@ -16,8 +16,8 @@ CREATE TABLE region ( r_regionkey integer NOT NULL, r_name char(25) NOT NULL, r_comment varchar(152), - INDEX region_cstore CLUSTERED COLUMNSTORE, -- column store - -- PRIMARY KEY (r_regionkey), -- row store + -- INDEX region_cstore CLUSTERED COLUMNSTORE, -- column store + PRIMARY KEY (r_regionkey), -- row store INDEX r_rk UNIQUE (r_regionkey ASC), ); @@ -26,8 +26,8 @@ CREATE TABLE nation ( n_name char(25) NOT NULL, n_regionkey integer NOT NULL, n_comment varchar(152), - INDEX nation_cstore CLUSTERED COLUMNSTORE, -- column store - -- PRIMARY KEY (n_nationkey), -- row store + -- INDEX nation_cstore CLUSTERED COLUMNSTORE, -- column store + PRIMARY KEY (n_nationkey), -- row store INDEX n_nk UNIQUE (n_nationkey ASC), INDEX n_rk (n_regionkey ASC), FOREIGN KEY (n_regionkey) REFERENCES region (r_regionkey) @@ -43,8 +43,8 @@ CREATE TABLE part ( p_container char(10) NOT NULL, p_retailprice decimal(15, 2) NOT NULL, p_comment varchar(23) NOT NULL, - INDEX part_cstore CLUSTERED COLUMNSTORE, -- column store - -- PRIMARY KEY (p_partkey), -- row store + -- INDEX part_cstore CLUSTERED COLUMNSTORE, -- column store + PRIMARY KEY (p_partkey), -- row store INDEX p_pk UNIQUE (p_partkey ASC) ); @@ -56,8 +56,8 @@ CREATE TABLE supplier ( s_phone char(15) NOT NULL, s_acctbal decimal(15, 2) NOT NULL, s_comment varchar(101) NOT NULL, - INDEX supplier_cstore CLUSTERED COLUMNSTORE, -- column store - -- PRIMARY KEY (s_suppkey), -- row store + -- INDEX supplier_cstore CLUSTERED COLUMNSTORE, -- column store + PRIMARY KEY (s_suppkey), -- row store INDEX s_sk UNIQUE (s_suppkey ASC), INDEX s_nk (s_nationkey ASC), FOREIGN KEY (s_nationkey) REFERENCES nation (n_nationkey) @@ -69,8 +69,8 @@ CREATE TABLE partsupp ( ps_availqty integer NOT NULL, ps_supplycost decimal(15, 2) NOT NULL, ps_comment varchar(199) NOT NULL, - INDEX partsupp_cstore CLUSTERED COLUMNSTORE, -- column store - -- PRIMARY KEY (ps_partkey, ps_suppkey), -- row store + -- INDEX partsupp_cstore CLUSTERED COLUMNSTORE, -- column store + PRIMARY KEY (ps_partkey, ps_suppkey), -- row store INDEX ps_pk (ps_partkey ASC), INDEX ps_sk (ps_suppkey ASC), INDEX ps_pk_sk UNIQUE (ps_partkey ASC, ps_suppkey ASC), @@ -88,8 +88,8 @@ CREATE TABLE customer ( c_acctbal decimal(15, 2) NOT NULL, c_mktsegment char(10) NOT NULL, c_comment varchar(117) NOT NULL, - INDEX customer_cstore CLUSTERED COLUMNSTORE, -- column store - -- PRIMARY KEY (c_custkey), -- row store + -- INDEX customer_cstore CLUSTERED COLUMNSTORE, -- column store + PRIMARY KEY (c_custkey), -- row store INDEX c_ck UNIQUE (c_custkey ASC), INDEX c_nk (c_nationkey ASC), FOREIGN KEY (c_nationkey) REFERENCES nation (n_nationkey) @@ -105,8 +105,8 @@ CREATE TABLE orders ( o_clerk char(15) NOT NULL, o_shippriority integer NOT NULL, o_comment varchar(79) NOT NULL, - INDEX o_orderdate_idx CLUSTERED COLUMNSTORE, -- column store - -- PRIMARY KEY (o_orderkey), -- row store + -- INDEX o_orderdate_idx CLUSTERED COLUMNSTORE, -- column store + PRIMARY KEY (o_orderkey), -- row store INDEX o_ok UNIQUE (o_orderkey ASC), INDEX o_ck (o_custkey ASC), INDEX o_od (o_orderdate ASC), @@ -130,8 +130,8 @@ CREATE TABLE lineitem ( l_shipinstruct char(25) NOT NULL, l_shipmode char(10) NOT NULL, l_comment varchar(44) NOT NULL, - INDEX l_shipdate_idx CLUSTERED COLUMNSTORE, -- column store - -- PRIMARY KEY (l_orderkey, l_linenumber), -- row store + -- INDEX l_shipdate_idx CLUSTERED COLUMNSTORE, -- column store + PRIMARY KEY (l_orderkey, l_linenumber), -- row store INDEX l_ok (l_orderkey ASC), INDEX l_pk (l_partkey ASC), INDEX l_sk (l_suppkey ASC), From 1f2d647ca94ef7bb70a0977e25911eb26edb7001 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 22 Apr 2022 15:01:01 -0500 Subject: [PATCH 6/9] fixup --- src/main/resources/benchmarks/tpch/ddl-sqlserver.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql b/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql index 7e4e59d18..be46c7570 100644 --- a/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql +++ b/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql @@ -18,7 +18,7 @@ CREATE TABLE region ( r_comment varchar(152), -- INDEX region_cstore CLUSTERED COLUMNSTORE, -- column store PRIMARY KEY (r_regionkey), -- row store - INDEX r_rk UNIQUE (r_regionkey ASC), + INDEX r_rk UNIQUE (r_regionkey ASC) ); CREATE TABLE nation ( From 6f74e0b0ad99b98888876d89a8d46f6629e66df8 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 22 Apr 2022 16:05:48 -0500 Subject: [PATCH 7/9] workaround a bug where benchbase doesn't parse trailing comments correctly ... when passing them along to the target server --- config/sqlserver/sample_tpch_config.xml | 2 +- .../benchmarks/tpch/ddl-sqlserver.sql | 58 +++++++++++++------ 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/config/sqlserver/sample_tpch_config.xml b/config/sqlserver/sample_tpch_config.xml index 078aad778..76d1695ad 100644 --- a/config/sqlserver/sample_tpch_config.xml +++ b/config/sqlserver/sample_tpch_config.xml @@ -4,7 +4,7 @@ sqlserver com.microsoft.sqlserver.jdbc.SQLServerDriver - jdbc:sqlserver://localhost:1433;encrypt=false;database=benchbase_tpch; + jdbc:sqlserver://sqlserver:1433;encrypt=false;database=benchbase_tpch; benchuser01 P@ssw0rd TRANSACTION_SERIALIZABLE diff --git a/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql b/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql index be46c7570..ed144c4c1 100644 --- a/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql +++ b/src/main/resources/benchmarks/tpch/ddl-sqlserver.sql @@ -1,6 +1,6 @@ -- Adapted from the Postgres schema --- Note: To use different storage layouts during --create, +-- Note: To use different storage layouts during --create -- switch row/column store commented lines and rebuild. DROP TABLE IF EXISTS lineitem; @@ -16,8 +16,11 @@ CREATE TABLE region ( r_regionkey integer NOT NULL, r_name char(25) NOT NULL, r_comment varchar(152), - -- INDEX region_cstore CLUSTERED COLUMNSTORE, -- column store - PRIMARY KEY (r_regionkey), -- row store + -- column store: + -- INDEX region_cstore CLUSTERED COLUMNSTORE, + -- row store: + PRIMARY KEY (r_regionkey), + -- secondary indices: INDEX r_rk UNIQUE (r_regionkey ASC) ); @@ -26,8 +29,11 @@ CREATE TABLE nation ( n_name char(25) NOT NULL, n_regionkey integer NOT NULL, n_comment varchar(152), - -- INDEX nation_cstore CLUSTERED COLUMNSTORE, -- column store - PRIMARY KEY (n_nationkey), -- row store + -- column store: + -- INDEX nation_cstore CLUSTERED COLUMNSTORE, + -- row store: + PRIMARY KEY (n_nationkey), + -- secondary indicies: INDEX n_nk UNIQUE (n_nationkey ASC), INDEX n_rk (n_regionkey ASC), FOREIGN KEY (n_regionkey) REFERENCES region (r_regionkey) @@ -43,8 +49,11 @@ CREATE TABLE part ( p_container char(10) NOT NULL, p_retailprice decimal(15, 2) NOT NULL, p_comment varchar(23) NOT NULL, - -- INDEX part_cstore CLUSTERED COLUMNSTORE, -- column store - PRIMARY KEY (p_partkey), -- row store + -- column store: + -- INDEX part_cstore CLUSTERED COLUMNSTORE, + -- row store: + PRIMARY KEY (p_partkey), + -- secondary indicies: INDEX p_pk UNIQUE (p_partkey ASC) ); @@ -56,8 +65,11 @@ CREATE TABLE supplier ( s_phone char(15) NOT NULL, s_acctbal decimal(15, 2) NOT NULL, s_comment varchar(101) NOT NULL, - -- INDEX supplier_cstore CLUSTERED COLUMNSTORE, -- column store - PRIMARY KEY (s_suppkey), -- row store + -- column store: + -- INDEX supplier_cstore CLUSTERED COLUMNSTORE, + -- row store: + PRIMARY KEY (s_suppkey), + -- secondary indicies: INDEX s_sk UNIQUE (s_suppkey ASC), INDEX s_nk (s_nationkey ASC), FOREIGN KEY (s_nationkey) REFERENCES nation (n_nationkey) @@ -69,8 +81,11 @@ CREATE TABLE partsupp ( ps_availqty integer NOT NULL, ps_supplycost decimal(15, 2) NOT NULL, ps_comment varchar(199) NOT NULL, - -- INDEX partsupp_cstore CLUSTERED COLUMNSTORE, -- column store - PRIMARY KEY (ps_partkey, ps_suppkey), -- row store + -- column store: + -- INDEX partsupp_cstore CLUSTERED COLUMNSTORE, + -- row store: + PRIMARY KEY (ps_partkey, ps_suppkey), + -- secondary indices: INDEX ps_pk (ps_partkey ASC), INDEX ps_sk (ps_suppkey ASC), INDEX ps_pk_sk UNIQUE (ps_partkey ASC, ps_suppkey ASC), @@ -88,8 +103,11 @@ CREATE TABLE customer ( c_acctbal decimal(15, 2) NOT NULL, c_mktsegment char(10) NOT NULL, c_comment varchar(117) NOT NULL, - -- INDEX customer_cstore CLUSTERED COLUMNSTORE, -- column store - PRIMARY KEY (c_custkey), -- row store + -- column store: + -- INDEX customer_cstore CLUSTERED COLUMNSTORE, + -- row store: + PRIMARY KEY (c_custkey), + -- secondary indices: INDEX c_ck UNIQUE (c_custkey ASC), INDEX c_nk (c_nationkey ASC), FOREIGN KEY (c_nationkey) REFERENCES nation (n_nationkey) @@ -105,8 +123,11 @@ CREATE TABLE orders ( o_clerk char(15) NOT NULL, o_shippriority integer NOT NULL, o_comment varchar(79) NOT NULL, - -- INDEX o_orderdate_idx CLUSTERED COLUMNSTORE, -- column store - PRIMARY KEY (o_orderkey), -- row store + -- column store: + -- INDEX o_orderdate_idx CLUSTERED COLUMNSTORE, + -- row store: + PRIMARY KEY (o_orderkey), + -- secondary indices: INDEX o_ok UNIQUE (o_orderkey ASC), INDEX o_ck (o_custkey ASC), INDEX o_od (o_orderdate ASC), @@ -130,8 +151,11 @@ CREATE TABLE lineitem ( l_shipinstruct char(25) NOT NULL, l_shipmode char(10) NOT NULL, l_comment varchar(44) NOT NULL, - -- INDEX l_shipdate_idx CLUSTERED COLUMNSTORE, -- column store - PRIMARY KEY (l_orderkey, l_linenumber), -- row store + -- column store: + -- INDEX l_shipdate_idx CLUSTERED COLUMNSTORE, + -- row store: + PRIMARY KEY (l_orderkey, l_linenumber), + -- secondary indices: INDEX l_ok (l_orderkey ASC), INDEX l_pk (l_partkey ASC), INDEX l_sk (l_suppkey ASC), From 141fc70734e5398343fdd7b12d2a4827eb1b6bf5 Mon Sep 17 00:00:00 2001 From: Brian Kroth Date: Fri, 22 Apr 2022 16:10:17 -0500 Subject: [PATCH 8/9] backout a local testing change --- config/sqlserver/sample_tpch_config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/sqlserver/sample_tpch_config.xml b/config/sqlserver/sample_tpch_config.xml index 76d1695ad..078aad778 100644 --- a/config/sqlserver/sample_tpch_config.xml +++ b/config/sqlserver/sample_tpch_config.xml @@ -4,7 +4,7 @@ sqlserver com.microsoft.sqlserver.jdbc.SQLServerDriver - jdbc:sqlserver://sqlserver:1433;encrypt=false;database=benchbase_tpch; + jdbc:sqlserver://localhost:1433;encrypt=false;database=benchbase_tpch; benchuser01 P@ssw0rd TRANSACTION_SERIALIZABLE From d24d380248f9d5ffae39550a00df3f4c4ffde60f Mon Sep 17 00:00:00 2001 From: Dalitso Banda Date: Sun, 24 Apr 2022 21:57:34 -0700 Subject: [PATCH 9/9] remove inline comments from the sql --- src/main/java/com/oltpbenchmark/util/ScriptRunner.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/oltpbenchmark/util/ScriptRunner.java b/src/main/java/com/oltpbenchmark/util/ScriptRunner.java index 26cfaf245..c983dcef3 100644 --- a/src/main/java/com/oltpbenchmark/util/ScriptRunner.java +++ b/src/main/java/com/oltpbenchmark/util/ScriptRunner.java @@ -93,6 +93,8 @@ private void runScript(Connection conn, Reader reader) throws IOException, SQLEx command = new StringBuffer(); } String trimmedLine = line.trim(); + line = line.replaceAll("\\-\\-.*$", ""); // remove comments in line; + if (trimmedLine.startsWith("--") || trimmedLine.startsWith("//")) { LOG.debug(trimmedLine); } else if (trimmedLine.length() < 1) { @@ -103,8 +105,6 @@ private void runScript(Connection conn, Reader reader) throws IOException, SQLEx try (Statement statement = conn.createStatement()) { - // println(command); - boolean hasResults = false; final String sql = command.toString().trim(); if (stopOnError) {