Reputation: 1829
I created a second DataSource in my application.
I created it with HikariDataSource, since I had problems because it was disconnected.
Now it does not disconnect, but it is very slow
My configuration is the following:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: org.postgresql.Driver
jdbcUrl: jdbc:postgresql://xxx/xxx_pm
username: xxx
password: xxx
hikari:
idle-timeout: 10000
java:
@ConfigurationProperties(prefix = "spring.datasources.xxx")
public class DatabaseXXXConfiguration extends HikariConfig{
@Bean(name = "xxxDataSource")
public DataSource dataSource() throws SQLException {
return new HikariDataSource(this);
}
Can someone tell me how to improve performance.
They are small queries of tables with pagination of about 25 records and takes 4 seconds.
I have observed that a query that is 200 records of a select, takes 46 seconds, before it did in 2 seconds.
Before, they were thousandth of seconds.
Thank you.
Upvotes: 0
Views: 1384
Reputation: 11114
Extending HikariConfig and overriding getDataDource() is not a valid way to create a DataSource. The HikariDataSource constructor is going to copy the HikariConfig into an immutable instance of HikariConfig, which will not include your overridden method. I’m not sure what dynamics are occurring as a result, but you might end up with something that creates a new pool on every connection attempt.
Basically, don’t do this. Pick a standard pattern of initialization that does not require extending HikariCP classes.
Upvotes: 0