Hibernate Slow to Acquire Postgres Connection

前端 未结 6 1654
渐次进展
渐次进展 2020-11-30 20:39

I\'m having a really difficult time debugging this problem. Whenever I try to establish a connection with postgres, it takes a whole minute. After the connection is establis

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-30 21:04

    Almost 7 years later and this is still an issue...

    Turning the "temp" key off helps but it's a nuisance to enable properties one-by-one that would be auto-configured (see other answers).

    In case of Oracle and Teradata I didn't notice such a slowdown so I digged deep and found where the slowest part is: https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java#L2237

    This resultSet has in my case 372 rows (types). Then, for each driver fires couple of calls from https://github.com/pgjdbc/pgjdbc/blob/master/pgjdbc/src/main/java/org/postgresql/jdbc/TypeInfoCache.java#L204 which results in tons of SQL statements against the DB.

    No idea how to speed this up right now, luckily it's needed once and then it's cached.

提交回复
热议问题