繁体   English   中英

Spring Boot-@Transaction(readOnly = true)vs休眠搜索

[英]Spring Boot - @Transaction(readOnly=true) vs Hibernate Search

我面临以下问题:我有一个应用程序(微服务体系结构),一个服务负责在很大的postgresql数据库中查找许多数据。 该服务有很多“搜索器”,每个搜索器都从一个大数据库中获取数据。 执行大量的SELECT语句,这确实需要很多时间(我使用Spring Boot,Hibernate)。

问题是如何提高性能?

  • 使用标志readOnly = true @Transaction(readOnly = true)设置事务
  • 或使用Hibernate Search: http//hibernate.org/search/
  • 禁用所有交易? (使用SELECT语句禁用事务可以极大地提高性能吗?)
  • 还是其他?

你能提出什么? 我听说过,对于我来说,Hibernate Search可能会大大提高性能

还是其他?

我的堆栈:Spring Boot:

    <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.1.2.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
<dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.4-1206-jdbc42</version>
        </dependency>

我们使用许多这样的JPARepository:

@Repository
public interface MyRepository extends JpaRepository<MyEntity, Long> {
    Set<MyEntity> findByIdProductInAndIdClient(List<Long> productsIds, Long idClient);
}

我们也使用

  • @NamedQueries

我们有2个数据源(2个数据库,一个用于执行SELECT语句,一个用于执行SAVE语句)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM