Skip to content

Commit

Permalink
Incorporate option to execute write YSQL sample app workloads indefin…
Browse files Browse the repository at this point in the history
…itely with upserts (#93)

* Incorporate option to execute write YSQL sample app workloads indefinitely with upserts

* Removing on conflict clause from SQLInsets workload
  • Loading branch information
Sfurti-yb authored Apr 4, 2024
1 parent 74138b9 commit 29db96c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/yugabyte/sample/apps/SqlDataLoad.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ private PreparedStatement getPreparedInsert() throws Exception {

close(insConnection);
insConnection = getPostgresConnection();
insConnection.createStatement().execute("set yb_enable_upsert_mode = true");
preparedInsert = insConnection.prepareStatement(sb.toString());
}
return preparedInsert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ private PreparedStatement getPreparedInsertUser() throws Exception {
if (preparedInsertUser == null) {
String stmt = String.format("INSERT INTO %s (user_id, user_details) VALUES (?, ?);", getTable1Name());
if (preparedInsertUser == null) {
preparedInsertUser = getPostgresConnection().prepareStatement(stmt);
Connection connection = getPostgresConnection();
connection.createStatement().execute("set yb_enable_upsert_mode = true");
preparedInsertUser = connection.prepareStatement(stmt);
}
}
preparedInsertUserLocal = preparedInsertUser;
Expand All @@ -236,6 +238,7 @@ private PreparedStatement getPreparedInsertUserOrder() throws Exception {
getTable2Name());
if (preparedInsertOrder == null) {
Connection connection = getPostgresConnection();
connection.createStatement().execute("set yb_enable_upsert_mode = true");
connection.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
preparedInsertOrder = connection.prepareStatement(stmt);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ public long doRead() {

private PreparedStatement getPreparedInsert() throws Exception {
if (preparedInsert == null) {
preparedInsert = getPostgresConnection().prepareStatement(
Connection connection = getPostgresConnection();
connection.createStatement().execute("set yb_enable_upsert_mode = true");
preparedInsert = connection.prepareStatement(
String.format("INSERT INTO %s (region, k, v) VALUES (?, ?, ?)",
getTableName()));
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/yugabyte/sample/apps/SqlInserts.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ private PreparedStatement getPreparedInsert() throws Exception {
if (preparedInsert == null) {
close(insConnection);
insConnection = getPostgresConnection();
insConnection.createStatement().execute("set yb_enable_upsert_mode = true");
preparedInsert = insConnection.prepareStatement(
String.format("INSERT INTO %s (k, v) VALUES (?, ?);", getTableName()));
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/yugabyte/sample/apps/SqlSnapshotTxns.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ private PreparedStatement getPreparedInsert() throws Exception {
String.format("INSERT INTO %s (k, v) VALUES (?, ?);", getTableName()) +
"COMMIT;";
if (preparedInsert == null) {
preparedInsert = getPostgresConnection().prepareStatement(stmt);
Connection connection = getPostgresConnection();
connection.createStatement().execute("set yb_enable_upsert_mode = true");
preparedInsert = connection.prepareStatement(stmt);
}
return preparedInsert;
}
Expand Down

0 comments on commit 29db96c

Please sign in to comment.