问题
I've developed a Spring Batch App with the Postgres and particularly facing slow write to database issue for 3 Steps out of 20 steps. I'd like to share example which is taking most time among three.
Below is the table where I'm writing data and data count is 2,33,382 . I'm using Spring JDBC and in particular NamedParameterJdbcTemplate to perform the Batch update.
CREATE TABLE test.country (
last_update_date date NULL,
src_system varchar(20) NULL,
country_id varchar(255) NULL,
app_id varchar(255) NULL,
country_cd varchar(255) NULL,
lifecycle_status_cd varchar(10) NULL DEFAULT 'A'::character varying,
violated varchar(1) NULL
);
CREATE INDEX country_id_idx ON test.country USING btree (country_id) ;
I've already created spring.properties file and have already added
spring.jdbc.getParameterType.ignore=true
and also using
spring:
datasource:
url: jdbc:postgresql://XXXXXX:6432/nyTest?currentSchema=my_owner?useServerPrepStmts=false&rewriteBatchedStatements=true
username: root
password: root
driver-class: org.postgresql.Driver
But just to load 233382 records its taking 26.7006 minutes. Any quick help? Postgres version 9.6
来源:https://stackoverflow.com/questions/66142330/spring-batch-and-postgres-database-slow-write