- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
pgjdbc中的prepareThreshold
定义如下:
Determine the number of PreparedStatement executions required before switching over to use server side prepared statements. The default is five, meaning start using server side prepared statements on the fifth execution of the same PreparedStatement object. More information on server side prepared statements is available in the section called “Server Prepared Statements”.
我想知道这实际上给我们带来了什么好处?大多数网络服务器几个月都不会重新启动,所以所有数据库查询最终都会发送 5 次以上,所以给它一个星期左右的时间,所有准备好的语句都会存储在服务器上,不是吗?这只是为了让桌面应用程序受益吗?还是我遗漏了什么,比如“一段时间内的 5 个阈值”?
最佳答案
我知道您想知道为什么 JDBC 驱动程序在使用服务器端准备好的语句之前完全等待。
在不参与决策过程的情况下,我会说原因是准备语句意味着一定的开销(发送 Prepare、Bind 和 Execute 调用)。只有当您确信该语句将被重用时,才有意义这样做。
不要忘记准备语句还有其他用途,可以在多次执行时节省解析步骤:这是避免 SQL 注入(inject)的王道。仅此一项就可以证明准备好的语句是正确的,即使它只执行一次。
关于postgresql - pgjdbc中prepareThreshold = 5有什么好处?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56261410/
亲爱的 StackOverFlowers, 我在 Postgres 9.6 (Windows 10) 上尝试事件驱动的 LISTENER/NOTIFY。 我遵循了 Steve Taylor 在 htt
我正在编写一个查询 PostgreSQL 数据库的 Java 程序。我正在关注 this example,但在这里遇到了麻烦: connection = DriverManager.g
我正在使用 JDBI 连接到我的 Postgres 数据库。这一直很好用。今天我决定尝试用 PGJDBC-NG 替换 native Postgres 驱动程序司机。一切都很好,直到我尝试我的第一个简单
我是一名优秀的程序员,十分优秀!