You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SpringBoot并行查询PostgreSQL视图性能下降问题排查求助

性能瓶颈排查求助:SpringBoot 与 PostgreSQL 并行查询性能骤降

我不确定当前性能问题出在SpringBoot应用还是PostgreSQL数据库,想请大家帮忙排查瓶颈所在。我使用Docker部署了PostgreSQL 15.2(最新版本),通过SpringBoot应用的JPA对数据库视图执行30条并行SELECT查询时,单查询耗时随并行度提升出现大幅下降:

  • 单线程串行执行:单查询耗时60-100ms
  • 10线程并行:单查询耗时140-500ms
  • 30线程并行:单查询耗时500-900ms

我原本预期并行查询时单查询耗时能控制在100-200ms范围内。

当前连接池配置

spring.datasource.hikari.minimum-idle=40
spring.datasource.hikari.maximum-pool-size=50

查询耗时测量代码

查询耗时通过以下代码统计:

log.debug("Searching for customer by id " + id);
long start = System.currentTimeMillis();
List<Customer> customerList = this.customerRepository.findById(id);
log.debug("Finished " + (System.currentTimeMillis() - start) + "ms for customer by id " + id);

DAO层接口定义

public interface CustomerRepository extends JpaRepository<Customer, String>;

环境信息

  • 主机为8核CPU
  • PostgreSQL Docker容器无CPU或内存限制
  • SpringBoot应用与数据库同机部署

请问是否需要调整PostgreSQL配置?还是应用本身存在性能瓶颈?

内容的提问来源于stack exchange,提问作者Martin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 18:02:54