diff --git a/config/yugabyte/colocated/insert_batched_extra_index_0_colocated.yaml b/config/yugabyte/colocated/insert_batched_extra_index_0_colocated.yaml new file mode 100644 index 000000000..cbd7d5413 --- /dev/null +++ b/config/yugabyte/colocated/insert_batched_extra_index_0_colocated.yaml @@ -0,0 +1,32 @@ +type: YUGABYTE +createdb: drop database if exists cyugabyte; create database cyugabyte with colocated=true; +driver: com.yugabyte.Driver +url: jdbc:yugabytedb://localhost:5433/yugabyte?sslmode=require&ApplicationName=featurebench&reWriteBatchedInserts=true +username: yugabyte +password: +batchsize: 128 +isolation: TRANSACTION_REPEATABLE_READ +loaderthreads: 1 +terminals: 1 +works: + work: + time: 5 + active_terminals: 1 + rate: 1000 + warmup: 0 +microbenchmark: + class: com.oltpbenchmark.benchmarks.featurebench.customworkload.YBMicroBenchmarkInsertsBatched + properties: + setAutoCommit : true + create : + - DROP PROCEDURE if exists insert_demo; + - CREATE PROCEDURE insert_demo(_numRows int) + LANGUAGE plpgsql + AS $$ + DECLARE + BEGIN + insert into demo (id, col1, col2, col3, col4, col5, col6, col7, col8, col9, col10) select n, n, n, n, n, n, n, n, n, n, n from generate_series(1,_numRows) n; + END; + $$; + - drop table if exists demo; + - create table demo (id int not null primary key, col1 int not null, col2 int, col3 int, col4 int, col5 int, col6 int, col7 int, col8 int, col9 int, col10 int); diff --git a/config/yugabyte/colocated/insert_batched_extra_index_1_colocated.yaml b/config/yugabyte/colocated/insert_batched_extra_index_1_colocated.yaml new file mode 100644 index 000000000..9f214c04c --- /dev/null +++ b/config/yugabyte/colocated/insert_batched_extra_index_1_colocated.yaml @@ -0,0 +1,33 @@ +type: YUGABYTE +createdb: drop database if exists cyugabyte; create database cyugabyte with colocated=true; +driver: com.yugabyte.Driver +url: jdbc:yugabytedb://localhost:5433/yugabyte?sslmode=require&ApplicationName=featurebench&reWriteBatchedInserts=true +username: yugabyte +password: +batchsize: 128 +isolation: TRANSACTION_REPEATABLE_READ +loaderthreads: 1 +terminals: 1 +works: + work: + time: 5 + active_terminals: 1 + rate: 1000 + warmup: 0 +microbenchmark: + class: com.oltpbenchmark.benchmarks.featurebench.customworkload.YBMicroBenchmarkInsertsBatched + properties: + setAutoCommit : true + create : + - DROP PROCEDURE if exists insert_demo; + - CREATE PROCEDURE insert_demo(_numRows int) + LANGUAGE plpgsql + AS $$ + DECLARE + BEGIN + insert into demo (id, col1, col2, col3, col4, col5, col6, col7, col8, col9, col10) select n, n, n, n, n, n, n, n, n, n, n from generate_series(1,_numRows) n; + END; + $$; + - drop table if exists demo; + - create table demo (id int not null primary key, col1 int not null, col2 int, col3 int, col4 int, col5 int, col6 int, col7 int, col8 int, col9 int, col10 int); + - create unique index demo_idx1 on demo(col1); \ No newline at end of file diff --git a/config/yugabyte/colocated/insert_sequential_extra_index_0_colocated.yaml b/config/yugabyte/colocated/insert_sequential_extra_index_0_colocated.yaml new file mode 100644 index 000000000..14a033d5b --- /dev/null +++ b/config/yugabyte/colocated/insert_sequential_extra_index_0_colocated.yaml @@ -0,0 +1,32 @@ +type: YUGABYTE +createdb: drop database if exists cyugabyte; create database cyugabyte with colocated=true; +driver: com.yugabyte.Driver +url: jdbc:yugabytedb://localhost:5433/yugabyte?sslmode=require&ApplicationName=featurebench&reWriteBatchedInserts=true +username: yugabyte +password: +batchsize: 128 +isolation: TRANSACTION_REPEATABLE_READ +loaderthreads: 1 +terminals: 1 +works: + work: + time: 5 + active_terminals: 1 + rate: 1000 + warmup: 0 +microbenchmark: + class: com.oltpbenchmark.benchmarks.featurebench.customworkload.YBMicroBenchmarkInsertsSequential + properties: + setAutoCommit : true + create : + - DROP PROCEDURE if exists insert_demo; + - CREATE PROCEDURE insert_demo(_numRows int) + LANGUAGE plpgsql + AS $$ + DECLARE + BEGIN + insert into demo (id, col1, col2, col3, col4, col5, col6, col7, col8, col9, col10) select n, n, n, n, n, n, n, n, n, n, n from generate_series(1,_numRows) n; + END; + $$; + - drop table if exists demo; + - create table demo (id int not null primary key, col1 int not null, col2 int, col3 int, col4 int, col5 int, col6 int, col7 int, col8 int, col9 int, col10 int); diff --git a/config/yugabyte/colocated/insert_sequential_extra_index_1_colocated.yaml b/config/yugabyte/colocated/insert_sequential_extra_index_1_colocated.yaml new file mode 100644 index 000000000..6990c9e91 --- /dev/null +++ b/config/yugabyte/colocated/insert_sequential_extra_index_1_colocated.yaml @@ -0,0 +1,33 @@ +type: YUGABYTE +createdb: drop database if exists cyugabyte; create database cyugabyte with colocated=true; +driver: com.yugabyte.Driver +url: jdbc:yugabytedb://localhost:5433/yugabyte?sslmode=require&ApplicationName=featurebench&reWriteBatchedInserts=true +username: yugabyte +password: +batchsize: 128 +isolation: TRANSACTION_REPEATABLE_READ +loaderthreads: 1 +terminals: 1 +works: + work: + time: 5 + active_terminals: 1 + rate: 1000 + warmup: 0 +microbenchmark: + class: com.oltpbenchmark.benchmarks.featurebench.customworkload.YBMicroBenchmarkInsertsSequential + properties: + setAutoCommit : true + create : + - DROP PROCEDURE if exists insert_demo; + - CREATE PROCEDURE insert_demo(_numRows int) + LANGUAGE plpgsql + AS $$ + DECLARE + BEGIN + insert into demo (id, col1, col2, col3, col4, col5, col6, col7, col8, col9, col10) select n, n, n, n, n, n, n, n, n, n, n from generate_series(1,_numRows) n; + END; + $$; + - drop table if exists demo; + - create table demo (id int not null primary key, col1 int not null, col2 int, col3 int, col4 int, col5 int, col6 int, col7 int, col8 int, col9 int, col10 int); + - create unique index demo_idx1 on demo(col1); \ No newline at end of file diff --git a/config/yugabyte/non-colocated/insert_batched_extra_index_0.yaml b/config/yugabyte/non-colocated/insert_batched_extra_index_0.yaml new file mode 100644 index 000000000..806b674e6 --- /dev/null +++ b/config/yugabyte/non-colocated/insert_batched_extra_index_0.yaml @@ -0,0 +1,31 @@ +type: YUGABYTE +driver: com.yugabyte.Driver +url: jdbc:yugabytedb://localhost:5433/yugabyte?sslmode=require&ApplicationName=featurebench&reWriteBatchedInserts=true +username: yugabyte +password: +batchsize: 128 +isolation: TRANSACTION_REPEATABLE_READ +loaderthreads: 1 +terminals: 1 +works: + work: + time: 5 + active_terminals: 1 + rate: 1000 + warmup: 0 +microbenchmark: + class: com.oltpbenchmark.benchmarks.featurebench.customworkload.YBMicroBenchmarkInsertsBatched + properties: + setAutoCommit : true + create : + - DROP PROCEDURE if exists insert_demo; + - CREATE PROCEDURE insert_demo(_numRows int) + LANGUAGE plpgsql + AS $$ + DECLARE + BEGIN + insert into demo (id, col1, col2, col3, col4, col5, col6, col7, col8, col9, col10) select n, n, n, n, n, n, n, n, n, n, n from generate_series(1,_numRows) n; + END; + $$; + - drop table if exists demo; + - create table demo (id int not null primary key, col1 int not null, col2 int, col3 int, col4 int, col5 int, col6 int, col7 int, col8 int, col9 int, col10 int) split into 1 tablets; diff --git a/config/yugabyte/non-colocated/insert_batched_extra_index_1.yaml b/config/yugabyte/non-colocated/insert_batched_extra_index_1.yaml new file mode 100644 index 000000000..b33728130 --- /dev/null +++ b/config/yugabyte/non-colocated/insert_batched_extra_index_1.yaml @@ -0,0 +1,32 @@ +type: YUGABYTE +driver: com.yugabyte.Driver +url: jdbc:yugabytedb://localhost:5433/yugabyte?sslmode=require&ApplicationName=featurebench&reWriteBatchedInserts=true +username: yugabyte +password: +batchsize: 128 +isolation: TRANSACTION_REPEATABLE_READ +loaderthreads: 1 +terminals: 1 +works: + work: + time: 5 + active_terminals: 1 + rate: 1000 + warmup: 0 +microbenchmark: + class: com.oltpbenchmark.benchmarks.featurebench.customworkload.YBMicroBenchmarkInsertsBatched + properties: + setAutoCommit : true + create : + - DROP PROCEDURE if exists insert_demo; + - CREATE PROCEDURE insert_demo(_numRows int) + LANGUAGE plpgsql + AS $$ + DECLARE + BEGIN + insert into demo (id, col1, col2, col3, col4, col5, col6, col7, col8, col9, col10) select n, n, n, n, n, n, n, n, n, n, n from generate_series(1,_numRows) n; + END; + $$; + - drop table if exists demo; + - create table demo (id int not null primary key, col1 int not null, col2 int, col3 int, col4 int, col5 int, col6 int, col7 int, col8 int, col9 int, col10 int) split into 1 tablets; + - create unique index demo_idx1 on demo(col1) split into 1 tablets; \ No newline at end of file diff --git a/config/yugabyte/non-colocated/insert_sequential_extra_index_0.yaml b/config/yugabyte/non-colocated/insert_sequential_extra_index_0.yaml new file mode 100644 index 000000000..7564adc62 --- /dev/null +++ b/config/yugabyte/non-colocated/insert_sequential_extra_index_0.yaml @@ -0,0 +1,31 @@ +type: YUGABYTE +driver: com.yugabyte.Driver +url: jdbc:yugabytedb://localhost:5433/yugabyte?sslmode=require&ApplicationName=featurebench&reWriteBatchedInserts=true +username: yugabyte +password: +batchsize: 128 +isolation: TRANSACTION_REPEATABLE_READ +loaderthreads: 1 +terminals: 1 +works: + work: + time: 5 + active_terminals: 1 + rate: 1000 + warmup: 0 +microbenchmark: + class: com.oltpbenchmark.benchmarks.featurebench.customworkload.YBMicroBenchmarkInsertsSequential + properties: + setAutoCommit : true + create : + - DROP PROCEDURE if exists insert_demo; + - CREATE PROCEDURE insert_demo(_numRows int) + LANGUAGE plpgsql + AS $$ + DECLARE + BEGIN + insert into demo (id, col1, col2, col3, col4, col5, col6, col7, col8, col9, col10) select n, n, n, n, n, n, n, n, n, n, n from generate_series(1,_numRows) n; + END; + $$; + - drop table if exists demo; + - create table demo (id int not null primary key, col1 int not null, col2 int, col3 int, col4 int, col5 int, col6 int, col7 int, col8 int, col9 int, col10 int) split into 1 tablets; diff --git a/config/yugabyte/non-colocated/insert_sequential_extra_index_1.yaml b/config/yugabyte/non-colocated/insert_sequential_extra_index_1.yaml new file mode 100644 index 000000000..13b67f36b --- /dev/null +++ b/config/yugabyte/non-colocated/insert_sequential_extra_index_1.yaml @@ -0,0 +1,32 @@ +type: YUGABYTE +driver: com.yugabyte.Driver +url: jdbc:yugabytedb://localhost:5433/yugabyte?sslmode=require&ApplicationName=featurebench&reWriteBatchedInserts=true +username: yugabyte +password: +batchsize: 128 +isolation: TRANSACTION_REPEATABLE_READ +loaderthreads: 1 +terminals: 1 +works: + work: + time: 5 + active_terminals: 1 + rate: 1000 + warmup: 0 +microbenchmark: + class: com.oltpbenchmark.benchmarks.featurebench.customworkload.YBMicroBenchmarkInsertsSequential + properties: + setAutoCommit : true + create : + - DROP PROCEDURE if exists insert_demo; + - CREATE PROCEDURE insert_demo(_numRows int) + LANGUAGE plpgsql + AS $$ + DECLARE + BEGIN + insert into demo (id, col1, col2, col3, col4, col5, col6, col7, col8, col9, col10) select n, n, n, n, n, n, n, n, n, n, n from generate_series(1,_numRows) n; + END; + $$; + - drop table if exists demo; + - create table demo (id int not null primary key, col1 int not null, col2 int, col3 int, col4 int, col5 int, col6 int, col7 int, col8 int, col9 int, col10 int) split into 1 tablets; + - create unique index demo_idx1 on demo(col1) split into 1 tablets; \ No newline at end of file diff --git a/src/main/java/com/oltpbenchmark/benchmarks/featurebench/customworkload/YBMicroBenchmarkInsertsBatched.java b/src/main/java/com/oltpbenchmark/benchmarks/featurebench/customworkload/YBMicroBenchmarkInsertsBatched.java new file mode 100644 index 000000000..eac25e13d --- /dev/null +++ b/src/main/java/com/oltpbenchmark/benchmarks/featurebench/customworkload/YBMicroBenchmarkInsertsBatched.java @@ -0,0 +1,51 @@ +package com.oltpbenchmark.benchmarks.featurebench.customworkload; + +import com.oltpbenchmark.benchmarks.featurebench.YBMicroBenchmark; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Statement; +import org.apache.commons.configuration2.HierarchicalConfiguration; +import org.apache.commons.configuration2.tree.ImmutableNode; +import org.apache.log4j.Logger; + +public class YBMicroBenchmarkInsertsBatched extends YBMicroBenchmark { + public final static Logger LOG = + Logger.getLogger(com.oltpbenchmark.benchmarks.featurebench.customworkload + .YBMicroBenchmarkInsertsBatched.class); + + public YBMicroBenchmarkInsertsBatched( + HierarchicalConfiguration config) { + super(config); + this.loadOnceImplemented = true; + } + + public void loadOnce(Connection conn) throws SQLException { + String insertStmt = "call insert_demo(100);"; + PreparedStatement stmt = conn.prepareStatement(insertStmt); + stmt.execute(); + stmt.close(); + } + + public void executeOnce(Connection conn) throws SQLException { + String values = ""; + for (int i = 101; i <= 1000; i++) { + values += "("; + for (int col = 1; col <= 11; col++) { + values += String.format("%d", i); + if (col < 11) { + values += ","; + } + } + values += ")"; + if (i < 1000) { + values += ","; + } + } + + String insertStmt1 = String.format("insert into demo values %s;", values); + Statement stmtObj = conn.createStatement(); + stmtObj.execute(insertStmt1); + stmtObj.close(); + } +} diff --git a/src/main/java/com/oltpbenchmark/benchmarks/featurebench/customworkload/YBMicroBenchmarkInsertsSequential.java b/src/main/java/com/oltpbenchmark/benchmarks/featurebench/customworkload/YBMicroBenchmarkInsertsSequential.java new file mode 100644 index 000000000..afb54b118 --- /dev/null +++ b/src/main/java/com/oltpbenchmark/benchmarks/featurebench/customworkload/YBMicroBenchmarkInsertsSequential.java @@ -0,0 +1,40 @@ +package com.oltpbenchmark.benchmarks.featurebench.customworkload; + +import com.oltpbenchmark.benchmarks.featurebench.YBMicroBenchmark; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Statement; +import org.apache.commons.configuration2.HierarchicalConfiguration; +import org.apache.commons.configuration2.tree.ImmutableNode; +import org.apache.log4j.Logger; + +public class YBMicroBenchmarkInsertsSequential extends YBMicroBenchmark { + public final static Logger LOG = + Logger.getLogger(com.oltpbenchmark.benchmarks.featurebench.customworkload + .YBMicroBenchmarkInsertsSequential.class); + + public YBMicroBenchmarkInsertsSequential( + HierarchicalConfiguration config) { + super(config); + this.loadOnceImplemented = true; + } + + public void loadOnce(Connection conn) throws SQLException { + String insertStmt = "call insert_demo(100);"; + PreparedStatement stmt = conn.prepareStatement(insertStmt); + stmt.execute(); + stmt.close(); + } + + public void executeOnce(Connection conn) throws SQLException { + Statement stmtObj = conn.createStatement(); + for (int id = 101; id <= 1000; id++) { + String query = String.format( + "insert into demo values (%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)", + id, id, id, id, id, id, id, id, id, id, id); + stmtObj.execute(query); + } + stmtObj.close(); + } +}