-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Is hibernate.jdbc.batch_size useful at all?
PostPosted: Fri Jan 04, 2013 1:57 pm 
Newbie

Joined: Fri Jan 04, 2013 1:44 pm
Posts: 1
I've read some blog posts (eg: http://orapath.blogspot.com.br/2012/04/hibernate.html, http://abramsm.wordpress.com/2008/04/23/hibernate-batch-processing-why-you-may-not-be-using-it-even-if-you-think-you-are/) recomending to set hibernate.jdbc.batch_size configuration property to higher values in order to get better performance at processing batches.

However browsing Hibernate 4.1.8 source code, I could see that neither the field jdbcBatchSize from org.hibernate.cfg.Settings, nor the corresponding getter getJdbcBatchSize() method that reflect the settings of this property are used throughout the framework.

So is there any reason to configure this setting at all?

Thanks

Reginaldo


Top
 Profile  
 
 Post subject: Re: Is hibernate.jdbc.batch_size useful at all?
PostPosted: Wed Jan 09, 2013 5:03 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Following the relevant code-snippets in Hibernate 4.1.8:

org.hibernate.cfg.SettingsFactory.java
Code:
int batchSize = ConfigurationHelper.getInt(AvailableSettings.STATEMENT_BATCH_SIZE, properties, 0);
      if ( !meta.supportsBatchUpdates() ) {
         batchSize = 0;
      }
      if ( batchSize > 0 && debugEnabled ) {
         LOG.debugf( "JDBC batch size: %s", batchSize );
      }
      settings.setJdbcBatchSize(batchSize);


org.hibernate.engine.jdbc.batch.internal.BatchBuilderImpl.java
Code:
public class BatchBuilderImpl implements BatchBuilder, Configurable {

   private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, BatchBuilderImpl.class.getName() );

   private int size;

   public BatchBuilderImpl() {
   }

   @Override
   public void configure(Map configurationValues) {
      size = ConfigurationHelper.getInt( Environment.STATEMENT_BATCH_SIZE, configurationValues, size );
   }

   public BatchBuilderImpl(int size) {
      this.size = size;
   }

   public void setJdbcBatchSize(int size) {
      this.size = size;
   }

   @Override
   public Batch buildBatch(BatchKey key, JdbcCoordinator jdbcCoordinator) {
      LOG.tracef( "Building batch [size=%s]", size );
      return size > 1
            ? new BatchingBatch( key, jdbcCoordinator, size )
            : new NonBatchingBatch( key, jdbcCoordinator );
   }
        ...



I put some breakpoint to see if this pieces of code are effectively executed:
They get executed, so there's no reason why jdbc batching should not work anymore as described.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.