Description
M Claus opened SPR-11100 and commented
We notice a performance drop after we updated to a (much newer) library (3.2.5). We used to work on 3.0.5.
We connect to Oracle11g with ojdbc 11.2.0.4 drivers.
After some testing we noticed that the performance drop was introduced by a changed implementation in setNull. Our queries have lots of columns ~40 with many optional values. For every NULL value, the driver is now asked ps.getParameterMetaData().getParameterType(paramIndex). The drivers don't support this yet but will throw an exception.
We notice that calling this method 30ish times costs us extra time (around 100ms), which is quite noticable. Requests which require 2 inserts went from ~200ms to 400+ms. We omitted the getparametertype call by editing the source of 3.2.5 to check our hypothesis and the performance was restored to its old state.
Is it possible to cache the 'unsupported state' in case the databasedrivers do not support it, so it's only executed once per request.
Below is the oracle implementation of getParameterType
SQLException localSQLException = DatabaseError.createUnsupportedFeatureSqlException();
localSQLException.fillInStackTrace();
throw localSQLException;
PS: entered this issue as a bug because it impairs the function of the product
Somewhat related issue, different bug introduced due to the added functionality (#14818)
Affects: 3.2.5
Issue Links:
- NamedParameterJdbcTemplate for "insert / select" clause, set NULL value causes JConnect 7 (Sybase) problem - java.io.IOException: JZ0SL: Unsupported SQL type 0. - Affects 3.1.3.RELEASE, works in 3.1.1.RELEASE [SPR-10084] #14717 NamedParameterJdbcTemplate for "insert / select" clause, set NULL value causes JConnect 7 (Sybase) problem - java.io.IOException: JZ0SL: Unsupported SQL type 0. - Affects 3.1.3.RELEASE, works in 3.1.1.RELEASE
- JdbcTemplate cannot set null parameter with Oracle driver [SPR-10385] #15018 JdbcTemplate cannot set null parameter with Oracle driver
- spring-jdbc-3.2.6.RELEASE doesn't support JDK 5. [SPR-11313] #15937 spring-jdbc-3.2.6.RELEASE doesn't support JDK 5.
- PreparedStatement#getParameterMetaData() calls may trigger unwanted side effects [SPR-11386] #16013 PreparedStatement#getParameterMetaData() calls may trigger unwanted side effects
- Oracle 12c JDBC driver throws inconsistent exception from getParameterType (affecting setNull calls) [SPR-13825] #18398 Oracle 12c JDBC driver throws inconsistent exception from getParameterType (affecting setNull calls)
- Avoid repeated getParameterType calls for setNull with Oracle 12c driver [SPR-14574] #19143 Avoid repeated getParameterType calls for setNull with Oracle 12c driver
- Protect against getParameterType cursor leak with Oracle 12c JDBC driver [SPR-14629] #19196 Protect against getParameterType cursor leak with Oracle 12c JDBC driver
Referenced from: commits 2e15f94, 4c8a789
Backported to: 3.2.6
2 votes, 7 watchers