Skip to content

Commit

Permalink
Improve PostgreSQL INSERT performance
Browse files Browse the repository at this point in the history
Co-authored-by: David Phillips <david@acz.org>
  • Loading branch information
wendigo and electrum authored May 17, 2022
1 parent acfce2a commit 2d532b2
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@
import io.trino.plugin.jdbc.credential.CredentialProvider;
import org.postgresql.Driver;

import java.util.Properties;

import static com.google.inject.multibindings.OptionalBinder.newOptionalBinder;
import static io.airlift.configuration.ConfigBinder.configBinder;
import static io.trino.plugin.jdbc.JdbcModule.bindSessionPropertiesProvider;
import static org.postgresql.PGProperty.REWRITE_BATCHED_INSERTS;

public class PostgreSqlClientModule
extends AbstractConfigurationAwareModule
Expand All @@ -56,6 +59,8 @@ public void setup(Binder binder)
@ForBaseJdbc
public ConnectionFactory getConnectionFactory(BaseJdbcConfig config, CredentialProvider credentialProvider)
{
return new DriverConnectionFactory(new Driver(), config, credentialProvider);
Properties connectionProperties = new Properties();
connectionProperties.put(REWRITE_BATCHED_INSERTS.getName(), "true");
return new DriverConnectionFactory(new Driver(), config.getConnectionUrl(), connectionProperties, credentialProvider);
}
}

0 comments on commit 2d532b2

Please sign in to comment.