无法启用休眠统计信息
嗨。 我目前正在寻找优化数据库持久性的方法。 我在SpringBoot服务中使用的是JPA Hibernate,我想检查查询是否使用批处理。
要进行检查,我需要启用休眠统计信息日志。 我已经在我的application.properties中添加了这两个:
spring.jpa.properties.hibernate.generate_statistics = true
logging.level.org.hibernate.stat =调试
但是看来我的应用程序无视这些设置。
您知道为什么不显示统计信息吗?
谢谢。
答案 0 :(得分:2)
hibernate-core-5.4.10.Final出现了同样的问题,这为我启用了统计信息:
<logger name="org.hibernate.engine.internal.StatisticalLoggingSessionEventListener" level="INFO"/>
我的日志文件中的示例输出:
2020-02-13 17:27:57,188 [main] INFO (o.h.e.i.StatisticalLoggingSessionEventListener:258 end) - Session Metrics {
700 nanoseconds spent acquiring 1 JDBC connections;
0 nanoseconds spent releasing 0 JDBC connections;
2500 nanoseconds spent preparing 1 JDBC statements;
678100 nanoseconds spent executing 1 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;
939200 nanoseconds spent executing 1 flushes (flushing a total of 1 entities and 0 collections);
0 nanoseconds spent executing 0 partial-flushes (flushing a total of 0 entities and 0 collections)
答案 1 :(得分:0)