【发布时间】:2021-04-11 13:15:03
【问题描述】:
我正在运行一个基于 https://github.com/yahoo/elide-spring-boot-example 的示例应用程序
我删除了所有省略号引用,添加了我自己的域。它现在是一个使用休眠的基本 Spring Boot 应用程序。 我使用以下内容更新了 application.yaml 以
- 使用我自己的 SQL Server 数据库和方言
- 忽略 liquibase 更改日志
- 忽略 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
当运行带有调试输出的应用程序时,我注意到表单中有数千行选择语句
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 (?, ?, ?, ?, ?, ?, ?, ?, ?)
我没有写具体的查询。我认为这可能是查询计划缓存 Spring + Hibernate: Query Plan Cache Memory usage 但添加 plan_cache_max_size 没有任何区别。为什么会生成这些查询,我应该怎么做才能避免这种情况发生?
【问题讨论】:
标签: spring-boot hibernate