java - JPQL 请求的问题需要很长时间才能执行超过 600000 个注册
问题描述
我在 jpql 中有一个查询,通常会减少数据计数,问题是当表对他们超过 600000 条数据记录时。我使用 spring 数据,实体不包含任何关系(没有 OneToMany、OneToOne、ManyToOne .....)与 oracle 作为数据库..
我使用了 JpaRepository、crudRepository,我什至直接尝试使用 JDBC,返回需要 8 分钟到 30 分钟。我认为问题来自请求,所以我尝试了 findAll() 并且处理时间保持不变。我更改了 JVM -Xmx 和 -Xms 的设置以提供更多内存,但没有任何帮助。
这是我提出的要求:
公共接口 TestRepository 扩展 CrudRepository {
@Query(value = "select new Test(CONCAT(t.date1, t.stringTarget, t.numInfo), t.name, t.phone, t.numInfo, t.date1, t.cotations, t.stringTarget, p.code, p.design)"
+ " from Test t, PointVente p"
+ " WHERE t.ePdv = p.numero"
+ " AND t.date1 BETWEEN :dateBegin AND :dateEnd"
+ " AND (t.state <> 'ANCL' or t.state is null)"
+ " AND t.game in :game"
+ " AND t.type in :type"
+ " AND t.participe = 1"
+ " AND NOT EXISTS (select t2.numInfo, t2.date1"
+ " from Test t2"
+ " WHERE t2.date1 BETWEEN :dateBegin AND :dateEnd"
+ " AND (t2.state <> 'ANCL' or t2.state is null)"
+ " AND t2.game in :game"
+ " AND t2.type in :type"
+ " AND t2.participe = 1"
+ " AND t2.numInfo = t.numInfo"
+ " AND t2.date1 = t.date1"
+ " AND (t2.phone is null or t2.phone NOT IN (select b.phone from BlacklistTest b))"
+ " group by CONCAT(t2.date1, t2.numInfo), t2.name, t2.phone, t2.numInfo, t2.date1, t2.ePdv"
+ " having sum(t2.cotations) <= :target)"
+ " AND t.cotations > :target"
+ " AND (t.phone is null or t.phone NOT IN (select b.phone from BlacklistTest b))")
List<TestResult> findTest(@Param("dateBegin") Date dateBegin, @Param("dateEnd") Date dateEnd, @Param("game") List<String> game, @Param("type") List<String> type, @Param("target") BigDecimal target);
}
是否可以减少响应时间?
我可以请你帮忙。
解决方案
推荐阅读
- python-3.x - GridSearchCV 使用 predict 还是 predict_proba?
- kubernetes - Kubernetes - 添加工作节点后容器是否自动分配给节点?
- apache - MediaWiki 响应非常缓慢
- cmake - 使用 CMake 构建系统的子目录中 halide_library 的可见性
- mercurial - 为什么在 Mercurial 的 Strip 上执行预输出挂钩?
- c# - 提示用户在 textbox-ASP.net 中填写多行数据?
- python - 将同步函数定义为 async 并等待它有什么好处吗?
- ubuntu-18.04 - xrdp 和用户的 Ubuntu 18.04 问题
- quickblox - 在 quickblox 上删除用户时出错
- python - 如何自动重新启动此代码?