我正在使用JPAQuery来查询数据库并在检索数据库时面临延迟,我还提供了BatchSize,但看起来并没有兑现。查询大约需要2秒的时间来查询和检索,但是实际执行时间为19毫秒。请指教。
JPAQueryFactory queryFactory = new JPAQueryFactory(entityManager);
JPAQuery query = queryFactory.select(queryBase.getColumns()).distinct().from(entityPath);
joinConditionsList.forEach(addDynamicJoins(query));
query
.where(queryBase.getFilters())
.orderBy(queryBase.getOrderBy())
.offset(queryBase.getOffset())
.limit(50000);
long startTime = System.currentTimeMillis();
List<Tuple> list = query.fetch();
我在application.yml中提供了以下内容。
jpa:
show-sql: true
hibernate:
ddl-auto: none
batch_size: 234
naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
properties:
hibernate:
jdbc:
lob:
non_contextual_creation: true
batch_size: 235
temp:
use_jdbc_metadata_defaults: false
database-platform: org.hibernate.dialect.PostgreSQL9Dialect