Spring Batch and Postgres database slow write

柔情痞子 提交于 2021-02-19 08:22:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!