Which caching strategy is faster and how much?
1) Prepared pooling (through the pool of connections). No caching by application.
for (int i=0; i<1000; i++) { PreparedStatement preparedStatement = connection.prepareStatement(sql); preparedStatement.setObject(1, someValue); preparedStatement.executeQuery(); preparedStatement.close(); }
2) Application level caching. No Union prepared.
PreparedStatement preparedStatement = connection.prepareStatement(sql); for (int i=0; i<1000; i++) { preparedStatement.clearParameters(); preparedStatement.setObject(1, someValue); preparedStatement.executeQuery(); } preparedStatement.close();
This question is similar to Reusing PreparedStatement several times , except that I expect specific test results, and also taking into account the preparedness of PreparedStatement.
http://drupal.org/node/550124#comment-2224630 seems to indicate that application-level caching is more efficient than the PreparedStatement pool, but the difference is not significant. I would like to see more tests before I decide.
source share