apply Hikari's recommended MySQL Configuration (FINERACT-796)
from https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration and https://github.com/brettwooldridge/HikariCP/wiki/JDBC-Logging#mysql-connectorj
This commit is contained in:
committed by
Michael Vorburger ⛑️
parent
5f2ba51f5a
commit
53e8658d74
+21
@@ -86,11 +86,32 @@ public class TomcatJdbcDataSourcePerTenantService implements RoutingDataSourceSe
|
||||
config.setJdbcUrl(jdbcUrl);
|
||||
config.setUsername(tenantConnectionObj.getSchemaUsername());
|
||||
config.setPassword(tenantConnectionObj.getSchemaPassword());
|
||||
config.setMinimumIdle(tenantConnectionObj.getInitialSize());
|
||||
config.setMaximumPoolSize(tenantConnectionObj.getMaxActive());
|
||||
config.setConnectionTestQuery("SELECT 1");
|
||||
config.setValidationTimeout(tenantConnectionObj.getValidationInterval());
|
||||
config.setAutoCommit(true);
|
||||
|
||||
// https://github.com/brettwooldridge/HikariCP/wiki/MBean-(JMX)-Monitoring-and-Management
|
||||
config.setRegisterMbeans(true);
|
||||
|
||||
// https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration
|
||||
// These are the properties for each Tenant DB; the same configuration is also in src/main/resources/META-INF/spring/hikariDataSource.xml for the all Tenants DB -->
|
||||
config.addDataSourceProperty("cachePrepStmts", "true");
|
||||
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
||||
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
||||
config.addDataSourceProperty("useServerPrepStmts", "true");
|
||||
config.addDataSourceProperty("useLocalSessionState", "true");
|
||||
config.addDataSourceProperty("rewriteBatchedStatements", "true");
|
||||
config.addDataSourceProperty("cacheResultSetMetadata", "true");
|
||||
config.addDataSourceProperty("cacheServerConfiguration", "true");
|
||||
config.addDataSourceProperty("elideSetAutoCommits", "true");
|
||||
config.addDataSourceProperty("maintainTimeStats", "false");
|
||||
|
||||
// https://github.com/brettwooldridge/HikariCP/wiki/JDBC-Logging#mysql-connectorj
|
||||
config.addDataSourceProperty("logger", "com.mysql.jdbc.log.StandardLogger");
|
||||
config.addDataSourceProperty("logSlowQueries", "true");
|
||||
config.addDataSourceProperty("dumpQueriesOnException", "true");
|
||||
|
||||
return new HikariDataSource(config);
|
||||
}
|
||||
|
||||
@@ -44,21 +44,26 @@
|
||||
<property name="idleTimeout" value="60000" />
|
||||
<property name="ConnectionTestQuery" value="SELECT 1" />
|
||||
|
||||
<!-- https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration -->
|
||||
<!-- These are the properties for the all Tenants DB; the same configuration is also (hard-coded) in the TomcatJdbcDataSourcePerTenantService class -->
|
||||
<property name="dataSourceProperties">
|
||||
<props>
|
||||
<!-- https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration -->
|
||||
<prop key="cachePrepStmts">true</prop>
|
||||
<prop key="prepStmtCacheSize">250</prop>
|
||||
<prop key="prepStmtCacheSqlLimit">2048</prop>
|
||||
<prop key="useServerPrepStmts">true</prop>
|
||||
<prop key="useLocalSessionState">true</prop>
|
||||
|
||||
<prop key="rewriteBatchedStatements">true</prop>
|
||||
<prop key="cacheResultSetMetadata">true</prop>
|
||||
<prop key="cacheServerConfiguration">true</prop>
|
||||
<prop key="elideSetAutoCommits">true</prop>
|
||||
<prop key="maintainTimeStats">true</prop>
|
||||
<prop key="maintainTimeStats">false</prop>
|
||||
|
||||
<!-- https://github.com/brettwooldridge/HikariCP/wiki/JDBC-Logging#mysql-connectorj -->
|
||||
<prop key="logger">com.mysql.jdbc.log.StandardLogger</prop>
|
||||
<prop key="logSlowQueries">true</prop>
|
||||
<prop key="dumpQueriesOnException">true</prop>
|
||||
</props>
|
||||
</property>
|
||||
</property>
|
||||
</bean>
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user