Skip to content

Commit

Permalink
Change prepareThreshold to 1 as default
Browse files Browse the repository at this point in the history
  • Loading branch information
tedyu committed Aug 17, 2021
1 parent 0be2b6a commit 83a19e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public enum PGProperty {
* Sets the default threshold for enabling server-side prepare. A value of {@code -1} stands for
* forceBinary
*/
PREPARE_THRESHOLD("prepareThreshold", "5",
PREPARE_THRESHOLD("prepareThreshold", "1",
"Statement prepare threshold. A value of {@code -1} stands for forceBinary"),

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ public void testStatementDescribe() throws SQLException {
}

@Test
public void testBatchWithPrepareThreshold5() throws SQLException {
public void testBatchWithPrepareThreshold1() throws SQLException {
assumeBinaryModeRegular();
Assume.assumeTrue("simple protocol only does not support prepared statement requests",
preferQueryMode != PreferQueryMode.SIMPLE);
Expand All @@ -1331,7 +1331,7 @@ public void testBatchWithPrepareThreshold5() throws SQLException {
// When using a prepareThreshold of 5, a batch update should use server-side prepare
pstmt = con.prepareStatement("INSERT INTO batch_tab_threshold5 (id, val) VALUES (?,?)");
((PgStatement) pstmt).setPrepareThreshold(5);
for (int p = 0; p < 5; p++) {
for (int p = 0; p < 1; p++) {
for (int i = 0; i <= 5; i++) {
pstmt.setLong(1, i);
pstmt.setLong(2, i);
Expand All @@ -1340,9 +1340,9 @@ public void testBatchWithPrepareThreshold5() throws SQLException {
pstmt.executeBatch();
}
pstmt.close();
assertTrue("prepareThreshold=5, so the statement should be server-prepared",
assertTrue("prepareThreshold=1, so the statement should be server-prepared",
((PGStatement) pstmt).isUseServerPrepare());
assertEquals("prepareThreshold=5, so the statement should be server-prepared", 1,
assertEquals("prepareThreshold=1, so the statement should be server-prepared", 1,
getNumberOfServerPreparedStatements("INSERT INTO batch_tab_threshold5 (id, val) VALUES ($1,$2)"));
}

Expand Down

0 comments on commit 83a19e4

Please # to comment.