Uploaded image for project: 'Sakai'
  1. Sakai
  2. SAK-44851

Make hibernate generate_statistics configurable and false by default

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: RESOLVED
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 19.7 [Tentative], 20.3 [Tentative], 21.0 [Tentative], 22.0 [Tentative]
    • Fix Version/s: 22.0 [Tentative]
    • Component/s: Config
    • Labels:
    • Test Plan:
      Hide

      I don't entirely see any indication it's on or not. A developer could test changing the setting and setting the log value to see the information that is generated.
      If you set

      hibernate.generate_statistics=true
      log.config.count = 2
      log.config.1 = INFO.org.hibernate.engine.internal.StatisticalLoggingSessionEventListener
      log.config.2 = DEBUG.org.hibernate.SQL

      if you do this you'll see something like

      02-Jan-2021 14:05:12.886 INFO [Timer-1] org.hibernate.engine.internal.StatisticalLoggingSessionEventListener.end Session Metrics {
          9300 nanoseconds spent acquiring 1 JDBC connections;
          0 nanoseconds spent releasing 0 JDBC connections;
          28683100 nanoseconds spent preparing 1132 JDBC statements;
          1069874300 nanoseconds spent executing 1132 JDBC statements;
          0 nanoseconds spent executing 0 JDBC batches;
          978613700 nanoseconds spent performing 1132 L2C puts;
          0 nanoseconds spent performing 0 L2C hits;
          0 nanoseconds spent performing 0 L2C misses;
          798500 nanoseconds spent executing 1 flushes (flushing a total of 1132 entities and 0 collections);
          567990900 nanoseconds spent executing 1132 partial-flushes (flushing a total of 640146 entities and 640146 collections)
      

      If hibernate.generate_statistics=false (new default) the log just won't show any messages if you have it enabled.

      Show
      I don't entirely see any indication it's on or not. A developer could test changing the setting and setting the log value to see the information that is generated. If you set hibernate.generate_statistics= true log.config.count = 2 log.config.1 = INFO.org.hibernate.engine.internal.StatisticalLoggingSessionEventListener log.config.2 = DEBUG.org.hibernate.SQL if you do this you'll see something like 02-Jan-2021 14:05:12.886 INFO [Timer-1] org.hibernate.engine.internal.StatisticalLoggingSessionEventListener.end Session Metrics { 9300 nanoseconds spent acquiring 1 JDBC connections; 0 nanoseconds spent releasing 0 JDBC connections; 28683100 nanoseconds spent preparing 1132 JDBC statements; 1069874300 nanoseconds spent executing 1132 JDBC statements; 0 nanoseconds spent executing 0 JDBC batches; 978613700 nanoseconds spent performing 1132 L2C puts; 0 nanoseconds spent performing 0 L2C hits; 0 nanoseconds spent performing 0 L2C misses; 798500 nanoseconds spent executing 1 flushes (flushing a total of 1132 entities and 0 collections); 567990900 nanoseconds spent executing 1132 partial-flushes (flushing a total of 640146 entities and 640146 collections) If hibernate.generate_statistics=false (new default) the log just won't show any messages if you have it enabled.

      Description

      While doing some work lately I found this useful property for hibernate performance tuning and checked that it was already enabled and not possible to disable.

      In KNL-1583 a setting was added to the hibernate properties for generate_statistics. 

      Every article I've read

      https://thorben-janssen.com/how-to-activate-hibernate-statistics-to-analyze-performance-issues/
      https://www.baeldung.com/hibernate-common-performance-problems-in-logs

      indicates that having this true in production can lead to decreased performance. However it can be useful in development to uncover N+1 style issues.  I think we should make this configurable and also document better how to use this property. I was seeing some potential N+1 issues in assignment yesterday as it looked to be doing an inefficient query when pulling down submissions.

      I don't know the performance impact of having this on but there's no point if it's not even logged by default. 

        Gliffy Diagrams

          Zeplin

            Attachments

              Issue Links

                Activity

                  People

                  Assignee:
                  jonespm Matthew Jones
                  Reporter:
                  jonespm Matthew Jones
                  Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                    Dates

                    Created:
                    Updated:
                    Resolved:

                      Git Integration