Optimizer Hints in PostgreSQL
Thursday, September 10 at 11:35–12:20
Optimizer hints are instructions to a (relational) database on how a specific SQL query should be executed. Unlike other relational databases such as Oracle, SQL Server or MySQL, PostgreSQL has traditionally not provided the DBA with optimizer hints. The developers’ position was that optimizer issues are bugs to be fixed, which is not always possible in practice, however.
Besides optimizer hints, PostgreSQL has always had the ability to influence the planner’s decisions by modifying optimizer parameters. Furthermore, the external pg_hint_plans extension enables optimizer hints and has been available for some time. In the upcoming version 19 of PostgreSQL, optimizer hints will be available directly within PostgreSQL for the first time.
This presentation provides an overview of the various ways to influence the PostgreSQL optimizer. It also uses examples to demonstrate how the pg_hint_plans extension and the optimizer hints in PostgreSQL 19 can be used.