PFC <lists@peufeu.com> writes:
>     And it is very easy to recognize a query we've seen before,
It's not so easy as all that.  Consider search_path.  Consider temp
tables.
The real problem here is entirely on the client side:
>     But, using prepared statements with persistent connections is messy,  
> because you never know if the connection is new or not,
If you were to fix *that* then both this problem and others (such as
setting up desired SET-parameter values) would go away.
        regards, tom lane