cockroachdb / cockroachdb/cockroach

sql: support pg_hint_plan-style optimizer hints

Open
#115,306 1 comment 0 reactions 0 assignees View on GitHub
A-sql-optimizer A-sql-syntax C-wishlist O-support P-3 T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

[pg_hint_plan](https://github.com/ossc-db/pg_hint_plan) is a PostgreSQL extension that allows optimizer hints to be provided in [a block comment before the query](https://github.com/ossc-db/pg_hint_plan/blob/master/docs/hint_details.md), for example:

```sql
/*+
NestLoop(t1 t2)
MergeJoin(t1 t2 t3)
Leading(t1 t2 t3)
*/
SELECT * FROM table1 t1
JOIN table table2 t2 ON (t1.key = t2.key)
JOIN table table3 t3 ON (t2.key = t3.key);
```

This is often easier for applications to generate than the inline hints we currently support.

Epic: CRDB-22192

Jira issue: CRDB-33971

Contributor guide

Open the contributing guide

Research direction

Start with pg_hint_plan's hint_details.md and the block-comment example in the issue. Compare that syntax with CockroachDB's existing inline hints, then identify the parser and optimizer entry points that handle hints. Done means block comments using the described syntax are accepted and their hints affect query planning without breaking existing hint behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.