PostgreSQL Generic vs Custom Plans
A prepared query can be fast for one parameter value and slow for another without any change to the SQL. Here is how PostgreSQL chooses between generic and custom plans, and how to investigate when the choice goes wrong.

