cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
30.15k stars 3.81k forks source link

sql: support pg_hint_plan-style optimizer hints #115306

Open michae2 opened 11 months ago

michae2 commented 11 months ago

pg_hint_plan is a PostgreSQL extension that allows optimizer hints to be provided in a block comment before the query, for example:

/*+
   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

michae2 commented 11 months ago

(Thanks to @drewdeally for this suggestion.)