The prepareThreshold in pgjdbc have the following definition:
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”.
I wonder what benefit this actually brings us? Most webservers aren't restarted for months, so all database queries will be sent more than 5 times eventually, so give it a week or so and all prepared statements will be stored at the server, won't them? Is this only for benefiting desktop applications? Or am I missing something, like a "5 threshold over a period of time"?
I understand that you want to know why the JDBC driver waits at all before using a server side prepared statement.
Without being in on the decision process, I'd say that the reason is that preparing a statement implies a certain overhead (send a Prepare, a Bind and an Execute call). It makes sense to do that only once you can be confident that the statement is going to be reused.
Don't forget that there are other uses for prepared statements that saving the Parse step on multiple executions: it is the king's way to avoiding SQL injection. That alone justifies a prepared statement, even if it is executed only once.