0

I am running a sample app based on https://github.com/yahoo/elide-spring-boot-example

I removed all the elide references, added my own domains. Its now a basic spring boot app using hibernate. I updated the application.yaml with the following in order to

  1. Use my own SQL Server DB and dialect
  2. Ignore liquibase changelog
  3. Ignore ddl-auto
spring:
    application:
      name: Elide
    jpa:
      properties:
        hibernate:
          default_batch_fetch_size: 100
          query:
            plan_cache_max_size: 64
            plan_parameter_metadata_max_size: 32
            in_clause_parameter_padding: true
      hibernate:
        show_sql: true
        naming:
          physical-strategy: 'misc.CustomPhysicalNamingStrategy'
        dialect: 'org.hibernate.dialect.SQLServerDialect'
        ddl-auto: 'none'
        jdbc:
          use_scrollable_resultset: true       
    datasource:
      url: 'jdbc:sqlserver://localhost;databaseName=MYDATABASE'
      username: 'username'
      password: 'password'
      driver-class-name: 'com.microsoft.sqlserver.jdbc.SQLServerDriver'
      validation-query: "SELECT 1"    
    liquibase:
      change-log: 'classpath:db/changelog/changelog.xml'
      enabled: false

When running the app with debug output, I notice thousands of lines of select statements in the form

Static select for one-to-many ... select ... from AUDIT_DETAIL auditdetai0_ where auditdetai0_.AUDIT_ACTION_TYPE_ID in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Static select for one-to-many ... select ... from AUDIT_DETAIL auditdetai0_ where auditdetai0_.AUDIT_ACTION_TYPE_ID in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Static select for one-to-many ... select ... from AUDIT_DETAIL auditdetai0_ where auditdetai0_.AUDIT_ACTION_TYPE_ID in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Static select for one-to-many ... select ... from AUDIT_DETAIL auditdetai0_ where auditdetai0_.AUDIT_ACTION_TYPE_ID in (?, ?, ?, ?, ?, ?, ?, ?, ?)

I have no specific queries written. I thought it might be the query plan cache as per Spring + Hibernate: Query Plan Cache Memory usage but adding the plan_cache_max_size doesnt make any difference. Why are these queries generated, and what should I do to avoid prevent this?

user2046211
  • 356
  • 1
  • 4
  • 20

2 Answers2

0

Looks like you have some initialization logic that does some lazy loading.

Christian Beikov
  • 15,141
  • 2
  • 32
  • 58
0

I think hibernate simply builds a metedata map of queries that may be run against different entitites. Queries are not actually executed. The slowness was caused by a bug in the swagger document construction. The elide community has since resolved the issue.

user2046211
  • 356
  • 1
  • 4
  • 20