mihalcea_vlad wrote:
I use p6spy or datasource-proxy to visualize the batching outcome. You can also debug it and see if the batching is there or the Hibernate SQL output is misleading.
I see you use table generator which should allow JDBC batching.
Thanks for that pointer, that was very useful.
Yes, the batching does seem to be taking place:
Code:
2016-01-10 23:18:29.531-0500 INFO [biz.ianw.lanchecker.Main] - main() 0 fares already in db, adding 3582 new fares...
2016-01-10 23:18:29.533-0500 INFO [biz.ianw.lanchecker.Main] - main() Starting commit...
2016-01-10 23:18:29.554-0500 INFO [net.ttddyy.dsproxy.listener.CommonsQueryLoggingListener] - Name:, Time:1, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["select next_val as id_val from hibernate_sequence for update"], Params:[()]
2016-01-10 23:18:29.557-0500 INFO [net.ttddyy.dsproxy.listener.CommonsQueryLoggingListener] - Name:, Time:2, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["update hibernate_sequence set next_val= ? where next_val=?"], Params:[(1=2,2=1)]
...
2016-01-10 23:18:57.202-0500 INFO [net.ttddyy.dsproxy.listener.CommonsQueryLoggingListener] - Name:, Time:0, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["select next_val as id_val from hibernate_sequence for update"], Params:[()]
2016-01-10 23:18:57.202-0500 INFO [net.ttddyy.dsproxy.listener.CommonsQueryLoggingListener] - Name:, Time:0, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["update hibernate_sequence set next_val= ? where next_val=?"], Params:[(1=3583,2=3582)]
2016-01-10 23:18:58.190-0500 INFO [net.ttddyy.dsproxy.listener.CommonsQueryLoggingListener] - Name:, Time:658, Success:True, Type:Prepared, Batch:True, QuerySize:1, [b]BatchSize:3582[/b], Query:["insert into PriceData (departureDate, foundDateTimeUtc, intPrice, returnDate, routeCabinFares_id, stringPrice, id) values (?, ?, ?, ?, ?, ?, ?)"], Params:[(1=[B@71df3f5b,2=[B@21b842cf,3=3565,4=[B@4555272a,5=1,6=US$3,565.30,7=1),(1=[B@6d80624,2=[B@ef5c443,3=3565,4=[B@6d385168,5=1,6=US$3,565.30,7=2),(1=[B@1384792,2=[B@471788b7,3=3565,4=[B@67609bca,5=1,6=US$3,565.30,7=3),(1=[B@487c355f,2=[B@bbbff15,3=3565,4=[B@70929ce5,5=1,6=US$3,565.30,7=4),...
2016-01-10 23:19:00.768-0500 INFO [biz.ianw.lanchecker.Main] - main() Commit complete, starting close...
2016-01-10 23:19:00.776-0500 INFO [biz.ianw.lanchecker.Main] - main() Close complete
2016-01-10 23:19:00.776-0500 INFO [biz.ianw.lanchecker.Main] - main() Existing fares in db: 0; New fares added: 3582; Collection add in 1942 uSecs; Commit in 31233 mSecs
The timings are, presumably, greatly affected by the presence of the proxy, but they suggest that at least half of my commit time is being taken up by the select/update pairs to generate the id for the PriceData entries.
If I change to:
Code:
public class PriceData {
@TableGenerator(
name="pdGen",
allocationSize=1000)
@Id
@GeneratedValue(strategy=GenerationType.TABLE, generator="pdGen")
private Long id;
this seems to substantially reduce the commit time:
Code:
2016-01-11 01:16:37.971-0500 INFO [biz.ianw.lanchecker.Main] - main() No matching RCF data in database, will be added
2016-01-11 01:16:37.993-0500 INFO [net.ttddyy.dsproxy.listener.CommonsQueryLoggingListener] - Name:, Time:0, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["select next_val as id_val from hibernate_sequence for update"], Params:[()]
2016-01-11 01:16:37.995-0500 INFO [net.ttddyy.dsproxy.listener.CommonsQueryLoggingListener] - Name:, Time:2, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["update hibernate_sequence set next_val= ? where next_val=?"], Params:[(1=2,2=1)]
2016-01-11 01:16:38.041-0500 INFO [net.ttddyy.dsproxy.listener.CommonsQueryLoggingListener] - Name:, Time:2, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["select tbl.next_val from hibernate_sequences tbl where tbl.sequence_name=? for update"], Params:[(1=PriceData)]
2016-01-11 01:16:38.042-0500 INFO [net.ttddyy.dsproxy.listener.CommonsQueryLoggingListener] - Name:, Time:1, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["insert into hibernate_sequences (sequence_name, next_val) values (?,?)"], Params:[(1=PriceData,2=1)]
2016-01-11 01:16:38.043-0500 INFO [net.ttddyy.dsproxy.listener.CommonsQueryLoggingListener] - Name:, Time:1, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["update hibernate_sequences set next_val=? where next_val=? and sequence_name=?"], Params:[(1=1001,2=1,3=PriceData)]
2016-01-11 01:16:38.049-0500 INFO [net.ttddyy.dsproxy.listener.CommonsQueryLoggingListener] - Name:, Time:1, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["select tbl.next_val from hibernate_sequences tbl where tbl.sequence_name=? for update"], Params:[(1=PriceData)]
2016-01-11 01:16:38.050-0500 INFO [net.ttddyy.dsproxy.listener.CommonsQueryLoggingListener] - Name:, Time:1, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["update hibernate_sequences set next_val=? where next_val=? and sequence_name=?"], Params:[(1=2001,2=1001,3=PriceData)]
2016-01-11 01:16:38.233-0500 INFO [net.ttddyy.dsproxy.listener.CommonsQueryLoggingListener] - Name:, Time:0, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["select tbl.next_val from hibernate_sequences tbl where tbl.sequence_name=? for update"], Params:[(1=PriceData)]
2016-01-11 01:16:38.234-0500 INFO [net.ttddyy.dsproxy.listener.CommonsQueryLoggingListener] - Name:, Time:0, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["update hibernate_sequences set next_val=? where next_val=? and sequence_name=?"], Params:[(1=3001,2=2001,3=PriceData)]
2016-01-11 01:16:38.317-0500 INFO [net.ttddyy.dsproxy.listener.CommonsQueryLoggingListener] - Name:, Time:0, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["select tbl.next_val from hibernate_sequences tbl where tbl.sequence_name=? for update"], Params:[(1=PriceData)]
2016-01-11 01:16:38.319-0500 INFO [net.ttddyy.dsproxy.listener.CommonsQueryLoggingListener] - Name:, Time:1, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["update hibernate_sequences set next_val=? where next_val=? and sequence_name=?"], Params:[(1=4001,2=3001,3=PriceData)]
2016-01-11 01:16:38.401-0500 INFO [net.ttddyy.dsproxy.listener.CommonsQueryLoggingListener] - Name:, Time:0, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["select tbl.next_val from hibernate_sequences tbl where tbl.sequence_name=? for update"], Params:[(1=PriceData)]
2016-01-11 01:16:38.402-0500 INFO [net.ttddyy.dsproxy.listener.CommonsQueryLoggingListener] - Name:, Time:1, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["update hibernate_sequences set next_val=? where next_val=? and sequence_name=?"], Params:[(1=5001,2=4001,3=PriceData)]
2016-01-11 01:16:38.440-0500 INFO [biz.ianw.lanchecker.Main] - main() Starting commit...
2016-01-11 01:16:38.544-0500 INFO [net.ttddyy.dsproxy.listener.CommonsQueryLoggingListener] - Name:, Time:2, Success:True, Type:Prepared, Batch:True, QuerySize:1, BatchSize:1, Query:["insert into RouteCabinFares (cabin, destinationCity, originCity, paymentType, siteCountry, id) values (?, ?, ?, ?, ?, ?)"], Params:[(1=Premium Business,2=miami,3=lima,4=0,5=pe,6=1)]
2016-01-11 01:16:39.619-0500 INFO [net.ttddyy.dsproxy.listener.CommonsQueryLoggingListener] - Name:, Time:827, Success:True, Type:Prepared, Batch:True, QuerySize:1, BatchSize:3581, Query:["insert into PriceData (departureDate, foundDateTimeUtc, intPrice, returnDate, routeCabinFares_id, stringPrice, id) values (?, ?, ?, ?, ?, ?, ?)"], Params:[(1=[B@2691df5e,2=[B@748c63cc,3=8363,4=[B@11f11e95,5=1,6=US$8,362.98,7=1),(1=[B@2d123bb1,2=[B@5517a62,3=3565,4=[B@1254eb07,5=1,6=US$3,565.30,7=2),...,(1=[B@4aeb7ea5,2=[B@56b0059c,3=3530,4=[B@160ffb29,5=1,6=US$3,529.70,7=3580),(1=[B@7a44ad98,2=[B@6bcbea23,3=3530,4=[B@3d018e23,5=1,6=US$3,529.70,7=3581)]
2016-01-11 01:16:39.791-0500 INFO [biz.ianw.lanchecker.Main] - main() Commit complete, starting close...