該表擁有超過2億條記錄,但我需要限制選定的前500萬條記錄。我已經用jdbcCursorItemReader嘗試了大約2-3個小時來選擇並使用單步處理將其寫入csv文件,所以我選擇使用並行處理,即春季批量提供。
我,通過讓taskExecutor和JdbcPagingItemReader使每個5個單獨的文件百萬個,但問題是我無法在查詢參數中指定限制和偏移量子句。請幫助我。讚賞比這更好的方法。如何在Spring批處理中使用JdbcPagingItemReader中的limit和offset子句?
<bean id="itemReader" class="org.springframework.batch.item.database.JdbcPagingItemReader" scope="step">
<property name="dataSource" ref="dataSource" />
<property name="rowMapper">
<bean class="MyRowMapper" />
</property>
<property name="queryProvider">
<bean class="org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="sortKeys">
<map>
<entry key="esmeaddr" value="ASCENDING"/>
</map>
</property>
<property name="selectClause" value="elect cust_send,dest,msg,stime,dtime,dn_status,mid,rp,operator,circle,cust_mid,first_attempt,second_attempt,third_attempt,fourth_attempt,fifth_attempt,term_operator,term_circle,bindata,reason,tag1,tag2,tag3,tag4,tag5"
/>
<property name="fromClause" value="FROM bill_log " />
<property name="whereClause" value="where esmeaddr = '70897600000000' and country='India' and apptype='SMS' Limit 0,1000000" />
</bean>
</property>
<property name="pageSize" value="1000000" />
<property name="parameterValues">
<map>
<entry key="param1" value="#{jobExecutionContext[param1]}" />
<entry key="param2" value="#{jobExecutionContext[param2]}" />
</map>
</property>
</bean>
非常感謝@MichealMinella。所提供的鏈接幫助了我很多。 – geekyKishan