Java JOOQ with SQL 服务器:缓存查询

Java JOOQ with SQL Server: Caching queries

我正在将 JOOQ 与 Microsoft SQL Server 2019 一起使用。它在此参考文献中指出,

https://www.jooq.org/doc/latest/manual/sql-execution/performance-considerations/

It takes some time to construct jOOQ queries. If you can reuse the same queries, you might cache them.

JOOQ 是否删除了任何 Microsoft SQL 服务器缓存功能?我应该用 JOOQ 做些什么来缓存 sql 计划,或者 SQL 服务器会自动处理它吗?

SQL Server caching

Does jooq has any performance lead over simple sql in java

It takes some time to construct jOOQ queries. If you can reuse the same queries, you might cache them.

这是关于 SQL 字符串 的客户端生成,它会在您每次 运行 一个 SQL 时重新生成查询(with jOOQ's queries being all dynamic by default)。您在上面引用的同一页还说:

Optimise wisely

在极少数情况下,jOOQ 的客户端 开销可能会影响应用程序的吞吐量。在这些情况下,您可能有兴趣在客户端中缓存 SQL 字符串甚至准备好的语句,但只有当您可以 衡量 实际问题时才应该这样做。

Does JOOQ remove any of Microsoft SQL server caching abilities?

不,一点也不。所有 jOOQ 查询都创建为 JDBC PreparedStatement using bind values by default。您显然可以覆盖此默认设置,因为总是有这样做的理由,但默认设置是使用准备好的语句来使服务器端的准备语句缓存受益。

Is there anything I should do specifically with JOOQ to cache sql plans, or will SQL server automatically take care of it?

SQL服务器会自动处理。