Skip to content

Change prepareThreshold to 1 as default #10

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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