Mysql CP performance enhancements

This commit is contained in:
Gabriele C 2016-09-02 15:48:58 +02:00
parent c6b35688eb
commit 9fa5f2beea
2 changed files with 12 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.DatabaseSettings;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.util.RuntimeUtils;
import fr.xephi.authme.util.StringUtils;
import java.sql.Blob;
@ -100,6 +101,9 @@ public class MySQL implements DataSource {
ds = new HikariDataSource();
ds.setPoolName("AuthMeMYSQLPool");
// Pool size
ds.setMaximumPoolSize(RuntimeUtils.getCoreCount());
// Database URL
ds.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database);
@ -118,7 +122,7 @@ public class MySQL implements DataSource {
// Caching
ds.addDataSourceProperty("cachePrepStmts", "true");
ds.addDataSourceProperty("prepStmtCacheSize", "250");
ds.addDataSourceProperty("prepStmtCacheSize", "275");
ds.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
ConsoleLogger.info("Connection arguments loaded, Hikari ConnectionPool ready!");

View File

@ -0,0 +1,7 @@
package fr.xephi.authme.util;
public class RuntimeUtils {
public static int getCoreCount() {
return Runtime.getRuntime().availableProcessors();
}
}