Java Spring批处理JdbcBatchItemWriter

Java Spring批处理JdbcBatchItemWriter,java,spring,integration,batch-processing,enterprise,Java,Spring,Integration,Batch Processing,Enterprise,我正在对读写器使用块步骤。读卡器使用的是高页面大小为5000的JdbcPagingItemReader。编写器正在块步骤上使用提交间隔为5000的JdbcBatchItemWriter <batch:step id="createRecords"> <tasklet allow-start-if-complete="true" > <chunk reader="read

我正在对读写器使用块步骤。读卡器使用的是高页面大小为5000的JdbcPagingItemReader。编写器正在块步骤上使用提交间隔为5000的JdbcBatchItemWriter

    <batch:step id="createRecords">
                    <tasklet  allow-start-if-complete="true" >
                        <chunk reader="readTable"  writer="createNewRecords" 
                               commit-interval="5000" skip-limit="100" >
                       <skippable-exception-classes>
                       <batch:include class="java.lang.Exception"/>
                       </skippable-exception-classes>
                        </chunk>
                    </tasklet>
</batch:step>

当我使用这个区块步骤加载记录时,一切都如我所期望的那样工作。它一次插入5000条记录(当没有错误时),性能如预期。10000条记录在一分钟内处理完毕

但是,当我使用相同的块步骤(完全相同的读取器)并更改编写器用于执行更新语句的SQL时(与插入相反,在基本SQL更新中),应用程序最多需要30多分钟来执行50K条记录的更新,这很糟糕。SQL中针对整个表的单个update语句(几乎相同)在几秒钟内运行。如果可能的话,我想利用批处理

     <bean id="createNewRecords" class="org.springframework.batch.item.database.JdbcBatchItemWriter">
    <property name="dataSource" ref="dataSource" />   
    <property name="sql">
        <value>
            <![CDATA[        
            UPDATE  TABLE SET TABLE_COLUM = :test
            ]]>
        </value>
    </property>
    <property name="itemSqlParameterSourceProvider">
        <bean class="org.springframework.batch.item.database.BeanPropertyItemSqlParameterSourceProvider" />
    </property>        
</bean>


想知道这听起来像是配置问题吗?或者spring batchs JdbcBatchItemWriter对更新语句的处理是否有所不同???

您的模式中是否有触发器?如果是,那可能是问题所在


无论如何,我也会尝试缩短提交间隔。5000在我看来相当大,因为您说单个更新执行速度很快,这可能会有所帮助。

您的更新查询在每次调用时都会更新表中的每一行。它需要一个“where”子句,最好是基于唯一或主键索引