Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

add insert benchmarks for colocated vs non-colocated DB #30

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
@@ -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);
31 changes: 31 additions & 0 deletions config/yugabyte/non-colocated/insert_batched_extra_index_0.yaml
Original file line number Diff line number Diff line change
@@ -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;
32 changes: 32 additions & 0 deletions config/yugabyte/non-colocated/insert_batched_extra_index_1.yaml
Original file line number Diff line number Diff line change
@@ -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;
31 changes: 31 additions & 0 deletions config/yugabyte/non-colocated/insert_sequential_extra_index_0.yaml
Original file line number Diff line number Diff line change
@@ -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;
32 changes: 32 additions & 0 deletions config/yugabyte/non-colocated/insert_sequential_extra_index_1.yaml
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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<ImmutableNode> 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();
}
}
Original file line number Diff line number Diff line change
@@ -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<ImmutableNode> 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();
}
}