Search code examples
postgresqlspring-boothikaricptimescaledb

How do I set plan_cache_mode to force_custom_plan in my application?


I have a Spring Boot application with a REST service. I'm using PorstgreSQL as my database with TimescaleDB. I'm trying to set plan_cache_mode to force_custom_plan because I don't want it to switch to generic plan. I'm using Hikari to manage the datasource. How do I set it in the HikariDataSource?


Solution

  • You can set the parameter on the database or user level:

    CREATE ROLE|DATABASE somename SET plan_cache_mode = force_custom_plan;
    

    Then all new connections as that user or to that database get that setting.