Trained server-side statements consume server-side resources to store the execution plan for the agent. The threshold provides a heuristic that causes statements that are actually used βoftenβ for preparation. The definition of βoftenβ defaults to 5.
Please note that prepared statements on the server side may cause poor execution plans, since they are not based on the parameters passed during preparation. If the parameters passed to the prepared operator have different selectivity for a specific index (for example), then the general query plan of the prepared operator may be suboptimal. As another example, if you have a situation where the execution of the request is much more than the cost of creating an explanation plan, and the explanation plan is incorrectly set due to the lack of binding parameters, you might be better off not using the server side.
When the driver reaches the threshold, he will prepare the operator as follows:
if (!oneShot) {
The operator name is sent as part of the wired protocol that tells Postgres to prepare it on the server side.
source share