Results 1 to 4 of 4

Thread: How to reduce a batch job's execution time?

Threaded View

  1. #1
    Join Date
    Aug 2012
    Posts
    2

    Default How to reduce a batch job's execution time?

    I have problems with the execution speed for a new batch job where I’m using the spring batch framework.

    The job are reading and committing 10 customers at a time.

    From the log, it looks like the reading from the database is very slow. From the mapRow method is first called, the customers are processed (the process method is called), and the customers are written to the database (the write method is called) takes less than one second. But from the execution of the write is completed to the next time mapRow is called, takes approximately 10 seconds each time.

    Does anyone have experience with how a job can be configured to reduce the execution time?

    Code:
    @Configuration
    public class CustomerAndAccountReaderConfiguration {
    
        @Bean
        public ItemReader<CustomerAndAccountOldDTO> customerAndAccountReader(DataSource dataSource,
                PagingQueryProvider pagingQueryProvider, PersonDAO personDAO, AccountDAO accountDAO,
                AddressDAO addressDAO) throws Exception {
            JdbcPagingItemReader<CustomerAndAccountDTO> jdbcPagingItemReader = new JdbcPagingItemReader<CustomerAndAccountDTO>();
            jdbcPagingItemReader.setFetchSize(10);
            jdbcPagingItemReader.setDataSource(dataSource);
            jdbcPagingItemReader.setQueryProvider(pagingQueryProvider);
            jdbcPagingItemReader.setRowMapper(new CustomerRowMapper(personDAO, accountDAO, addressDAO));
            jdbcPagingItemReader.afterPropertiesSet();
            return jdbcPagingItemReader;
        }
    
        @Bean
        public PagingQueryProvider pagingQueryProvider() {
            Db2PagingQueryProvider db2PagingQueryProvider = new Db2PagingQueryProvider();
            db2PagingQueryProvider.setSelectClause("select * ");
            db2PagingQueryProvider.setFromClause("from Customer ");
            db2PagingQueryProvider.setSortKey("id");
            return db2PagingQueryProvider;
        }
    
    }
    
    
    
    <beans>
        <batch:job id="databaseconversion">
            <batch:step id="convertcustomerandaccount">
                <batch:tasklet>
                    <batch:chunk 
                        reader="customerAndAccountReader"
                        processor="customerAndAccountProcessor" 
                        writer="customerAndAccountWriter"
                        commit-interval="10" 
                    />
                </batch:tasklet>
            </batch:step>
        </batch:job>
    </beans>
    Last edited by Hallgeir; Aug 16th, 2012 at 02:05 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •