When executing a statement in Postgres you can set specific query planner configuration parameters as described in the documentation.
These can be set on a system level by the administrator or on a user level in a specific session. I now have the issue that the application does not support setting parameters in the user session, and I don't want to set it globally, since this would affect all queries.
Is it possible to set a query planning parameter via hints in the SQL itself (like in Oracle) or create a profile on a certain SQL statement to include certain parameters?
For context, the parameter I am talking about is plan_cache_mode. When it is set to auto, a certain prepared statement is using a generic plan that has very bad performance (~8s execution time). As soon as I force custom plans via force_custom_plan the execution time drops to ~10ms. I know that better indexes or statistics might change the generic plan, but I am looking for an easier solution than diving into SQL optimization.