pg_hint_plan
1. Overview
pg_hint_plan is a PostgreSQL extension that lets you control the execution plan chosen by the optimizer using special comments called "hints" embedded in SQL statements. It is fully compatible with IvorySQL.
2. Installation
3. Create Extension and Verify
Connect to the database with psql and execute the following commands:
ivorysql=# CREATE EXTENSION pg_hint_plan; CREATE EXTENSION ivorysql=# SELECT * FROM pg_available_extensions WHERE name = 'pg_hint_plan'; name | default_version | installed_version | comment --------------+-----------------+-------------------+--------------------------------- pg_hint_plan | 1.7.0 | 1.7.0 | Give optimizer hints
4. Usage Example
Hints are written as special comments at the start of a query. For example, to force a sequential scan on table t:
ivorysql=# EXPLAIN SELECT /*+ SeqScan(t) */ * FROM t;
See the pg_hint_plan documentation for the full list of supported hints.