[hibernate-issues] [Hibernate-JIRA] Created: (HHH-5790) method BasicBinder#bind() slow because formatting for trace is done also with disabled trace

Guenther Demetz (JIRA) noreply at atlassian.com
Mon Dec 13 08:53:13 EST 2010


method BasicBinder#bind() slow because formatting for trace is done also with disabled trace
--------------------------------------------------------------------------------------------

                 Key: HHH-5790
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5790
             Project: Hibernate Core
          Issue Type: Improvement
    Affects Versions: 3.6.0
         Environment: 3_6_0_final
            Reporter: Guenther Demetz


In the ELSE block of method org.hibernate.type.descriptor.sql.BasicBinder#bind
the if statement "if (log.isTraceEnabled())" is missing, so strings are formatted 
even if trace logging is disabled.

CURRENT CODE:

if ( value == null ) {
   if ( log.isTraceEnabled() ) {
	log.trace(String.format(...);
   }
   st.setNull( index, sqlDescriptor.getSqlType() );
}
else {
   log.trace(String.format(BIND_MSG_TEMPLATE,index, ...);
   doBind( st, value, index, options );
}

IMPROVEMENT:

if ( value == null ) {
   if ( log.isTraceEnabled() ) {
	log.trace(String.format(...);
   }
   st.setNull( index, sqlDescriptor.getSqlType() );
}
else {
   if ( log.isTraceEnabled() ) {                       //// NEW LINE
        log.trace(String.format(BIND_MSG_TEMPLATE,index, ...);
   }                                                   //// NEW LINE
   doBind( st, value, index, options );
}


BTW: By doing this little code enhancement, I was able to achieve almost the double speed when inserting data.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list