This looks like early vs late binding problem, also seen in  other products.  When you prepare the sql, the optimizer
has no way of knowing the values which is going to be supplied in future.  So it is possible that at the time of preparing
PG settles on a plan and uses it for all values, regardless of its efficiency.