Почему Hibernate замедляется через некоторое время? - PullRequest
1 голос
/ 24 марта 2020

В чем может быть причина того, что hibernate замедляется после выполнения тех же запросов (только для чтения)?

logs:

   368588 nanoseconds spent acquiring 1 JDBC connections;
   0 nanoseconds spent releasing 0 JDBC connections;
   158339 nanoseconds spent preparing 3 JDBC statements;
   33855736 nanoseconds spent executing 3 JDBC statements;
   0 nanoseconds spent executing 0 JDBC batches;
   0 nanoseconds spent performing 0 L2C puts;
   0 nanoseconds spent performing 0 L2C hits;
   0 nanoseconds spent performing 0 L2C misses;
   0 nanoseconds spent executing 0 flushes (flushing a total of 0 entities and 0 collections);
   9437 nanoseconds spent executing 3 partial-flushes (flushing a total of 0 entities and 0 collections)
}
2020-03-24 09:02:54.488  INFO 12024 --- [io-8064-exec-10] i.StatisticalLoggingSessionEventListener : Session Metrics {
   44640 nanoseconds spent acquiring 1 JDBC connections;
   0 nanoseconds spent releasing 0 JDBC connections;
   134337 nanoseconds spent preparing 3 JDBC statements;
   33256438 nanoseconds spent executing 3 JDBC statements;
   0 nanoseconds spent executing 0 JDBC batches;
   0 nanoseconds spent performing 0 L2C puts;
   0 nanoseconds spent performing 0 L2C hits;
   0 nanoseconds spent performing 0 L2C misses;
   0 nanoseconds spent executing 0 flushes (flushing a total of 0 entities and 0 collections);
   9156 nanoseconds spent executing 3 partial-flushes (flushing a total of 0 entities and 0 collections)
}
2020-03-24 09:02:56.143  INFO 12024 --- [nio-8064-exec-1] i.StatisticalLoggingSessionEventListener : Session Metrics {
   47060 nanoseconds spent acquiring 1 JDBC connections;
   0 nanoseconds spent releasing 0 JDBC connections;
   123461 nanoseconds spent preparing 3 JDBC statements;
   468759882 nanoseconds spent executing 3 JDBC statements;
   0 nanoseconds spent executing 0 JDBC batches;
   0 nanoseconds spent performing 0 L2C puts;
   0 nanoseconds spent performing 0 L2C hits;
   0 nanoseconds spent performing 0 L2C misses;
   0 nanoseconds spent executing 0 flushes (flushing a total of 0 entities and 0 collections);
   9680 nanoseconds spent executing 3 partial-flushes (flushing a total of 0 entities and 0 collections)
}

, как вы можете видеть из журналов выполнения время увеличивается в десять раз

1 Ответ

1 голос
/ 24 марта 2020

Hibernate c3p0 может быть настроен для повышения эффективности. Пул соединений хорош для производительности, так как он предотвращает создание приложением Java соединения каждый раз при взаимодействии с базой данных и сводит к минимуму стоимость открытия и закрытия соединений.

Попробуйте эту ссылку для настройки hibernate c3p0 в вашем приложении:

https://mkyong.com/hibernate/how-to-configure-the-c3p0-connection-pool-in-hibernate/

...