出于某种原因,休眠的postgres连接会减慢我的应用程序的启动速度

时间:2019-07-16 13:52:59

标签: java postgresql hibernate

我的应用程序在INFO中启动:服务器启动时间为[337,971]毫秒

我尝试将hibernate.temp.use_jdbc_metadata_defaults设置为false。 我尝试将hibernate.dialect设置为org.hibernate.dialect.PostgreSQLDialect

我可以使用pgadmin在ms内连接到Postgres服务器,也可以在短时间内查询。

问题出在应用程序中。

jdbc.prefetchsize=10
jdbc.maximumPoolSize=1
jdbc.minimumIdle=0
jdbc.idleTimeout=30000
<property name="jpaProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.format_sql">false</prop>
            <prop key="hibernate.generate_statistics">false</prop>
            <prop key="hibernate.auditable">true</prop>
            <prop key="org.hibernate.envers.audit_table_prefix">Z_</prop>
            <prop key="hibernate.temp.use_jdbc_metadata_defaults">false</prop>
        </props>
    </property>

这是有问题的部分的控制台日志:

16:41:07.395 [HikariPool-1 housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Before cleanup stats (total=1, active=0, idle=1, waiting=0)
16:41:07.396 [HikariPool-1 housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - After cleanup  stats (total=1, active=0, idle=1, waiting=0)
16:41:37.401 [HikariPool-1 housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Before cleanup stats (total=1, active=0, idle=1, waiting=0)
16:41:37.401 [HikariPool-1 housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - After cleanup  stats (total=0, active=0, idle=0, waiting=0)
16:41:37.401 [HikariPool-1 connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Closing connection org.postgresql.jdbc.PgConnection@4bfc28ec: (connection has passed idleTimeout)
16:42:07.401 [HikariPool-1 housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Before cleanup stats (total=0, active=0, idle=0, waiting=0)
16:42:07.402 [HikariPool-1 housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - After cleanup  stats (total=0, active=0, idle=0, waiting=0)
16:42:37.403 [HikariPool-1 housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Before cleanup stats (total=0, active=0, idle=0, waiting=0)
16:42:37.403 [HikariPool-1 housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - After cleanup  stats (total=0, active=0, idle=0, waiting=0)
16:43:07.404 [HikariPool-1 housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Before cleanup stats (total=0, active=0, idle=0, waiting=0)
16:43:07.404 [HikariPool-1 housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - After cleanup  stats (total=0, active=0, idle=0, waiting=0)
16:43:37.407 [HikariPool-1 housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Before cleanup stats (total=0, active=0, idle=0, waiting=0)
16:43:37.408 [HikariPool-1 housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - After cleanup  stats (total=0, active=0, idle=0, waiting=0)
16:44:07.408 [HikariPool-1 housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Before cleanup stats (total=0, active=0, idle=0, waiting=0)
16:44:07.409 [HikariPool-1 housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - After cleanup  stats (total=0, active=0, idle=0, waiting=0)
Jul 16, 2019 4:44:29 PM com.etstur.cs.backend.datasrvds.impl.RuleContainer getMap
INFO: Rule map refilled in 219127ms
16:44:30.078 [HikariPool-1 connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@110cb9bc
Hibernate: select autocomple0_.id as id1_13_, autocomple0_.status as status2_13_, autocomple0_.text as text3_13_ from AutoCompleteWhiteList autocomple0_ where autocomple0_.status='ACTIVE'
Hibernate: select hotel_id from black_friday_hotels
Initializing ExecutorService 'taskExecutor'
Root WebApplicationContext initialized in 324837 ms

0 个答案:

没有答案