How negligible is the ParameterizedBeanPropertyRowMapper parameter?

The javadoc says:

Please note that this class is intended to provide convenience rather than high performance. For best performance, consider using a custom RowMapper.

How slowly does this happen in the real world?

+4
source share
3 answers

Profiling results of the mapRow method with Yourkit:

Custom row mapper: 186 ms (invocation count 224 (weird...)) ParameterizedBeanPropertyRowMapper: 1301 ms (invocation count 112) 

Output:

When reading one row from a result set, 11 milliseconds are saved. This means that 1 β€œvirtual” second is saved when reading 100 records. Multiply this by the number of users, and you get this idea. ParameterizedBeanPropertyRowMapper can only be effectively used in small applications that run on the client machine (desktop applications).

+2
source

Calling methods using reflection gives you a performance hit right from the start. In this situation, you multiply this performance by the number of results coming from the database. If your data will grow and you will often request it, consider using the ParameterizedRowMapper parameter.

In the past, I had to abandon the use of convenient libraries with satisfactory needs, because tests showed that he turned to the user for 100 ms, looking at about 3 seconds.

+3
source

I never compared this because I never considered this a bottleneck. A custom RowMapper that does not use reflection will be faster, but I have never seen my applications worry about what needs to be worried. If you are making an application with extremely high performance, then this may be worth a look, but for most purposes, I think that convenience is worth a minor blow.

Look at the source code of the base class, AbstractBeanPropertyRowMapper, that a lot of reflection style code is cached after the first access to the class through this resolver. I can’t imagine that there are any real performance issues. Quick view: http://www.java2s.com/Open-Source/Java-Document/J2EE/spring-framework-2.5/org/springframework/jdbc/core/AbstractBeanPropertyRowMapper.java.htm

+2
source

All Articles