Skip to content

Hint injection docs#20830

Merged
taroface merged 8 commits into
mainfrom
hint-injection
Jan 29, 2026
Merged

Hint injection docs#20830
taroface merged 8 commits into
mainfrom
hint-injection

Conversation

@taroface
Copy link
Copy Markdown
Contributor

@taroface taroface commented Oct 28, 2025

DOC-15510
DOC-15833
DOC-15834
DOC-15838
DOC-15836
DOC-15276
DOC-15422

@netlify
Copy link
Copy Markdown

netlify Bot commented Oct 28, 2025

Deploy Preview for cockroachdb-api-docs canceled.

Name Link
🔨 Latest commit a2bcebe
🔍 Latest deploy log https://app.netlify.com/projects/cockroachdb-api-docs/deploys/697ba0ecc201a00008ad2440

@netlify
Copy link
Copy Markdown

netlify Bot commented Oct 28, 2025

Deploy Preview for cockroachdb-interactivetutorials-docs canceled.

Name Link
🔨 Latest commit a2bcebe
🔍 Latest deploy log https://app.netlify.com/projects/cockroachdb-interactivetutorials-docs/deploys/697ba0ecd604df0008a3b2d4

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Oct 28, 2025

@netlify
Copy link
Copy Markdown

netlify Bot commented Oct 28, 2025

Netlify Preview

Name Link
🔨 Latest commit a2bcebe
🔍 Latest deploy log https://app.netlify.com/projects/cockroachdb-docs/deploys/697ba0ec48047c00087d06ba
😎 Deploy Preview https://deploy-preview-20830--cockroachdb-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@taroface taroface force-pushed the hint-injection branch 2 times, most recently from 95d85db to 73b7928 Compare January 21, 2026 23:42
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 21, 2026

Cross-Version Link Check Passed

All cross-version link issues have been resolved. Good job!

@taroface taroface changed the title [WIP] hint injection docs Hint injection docs Jan 21, 2026
Copy link
Copy Markdown

@michae2 michae2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These docs are great! Just a couple corrections.

Comment thread src/current/v26.1/cost-based-optimizer.md Outdated
Comment thread src/current/v26.1/cost-based-optimizer.md Outdated
Comment thread src/current/v26.1/cost-based-optimizer.md Outdated
Comment thread src/current/v26.1/cost-based-optimizer.md Outdated
Comment thread src/current/v26.1/cost-based-optimizer.md Outdated
{{site.data.alerts.callout_info}}
The `statement hints count` field shows the number of individual hints applied. A single row in `system.statement_hints` can contain multiple hints (such as an index hint and a join hint).
{{site.data.alerts.end}}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of cockroachdb/cockroach#161043 there's also a new metric, sql.query.with_statement_hints.count, which counts the number of statement executions that used statement hints.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the issue to document this metric. However, apparently metrics.yaml now has a visibility field that (separately from the presence of a release note) determines whether these metrics are supposed to be documented. Since this metric doesn't appear to have that field, and I'm not clear on this metrics policy right now, I'll have to defer this for now. Let me know if it's meant to have visibility though.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Let's skip documenting it for now.

Comment thread src/current/v26.1/cost-based-optimizer.md Outdated
Comment thread src/current/v26.1/cost-based-optimizer.md Outdated
Comment thread src/current/v26.1/cost-based-optimizer.md Outdated
@taroface
Copy link
Copy Markdown
Contributor Author

@michae2 Updated per your comments. PTAL!

@taroface taroface requested a review from michae2 January 22, 2026 21:48
Copy link
Copy Markdown

@michae2 michae2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!

);
~~~

Fingerprints distinguish between queries with different inline hints. For example, the fingerprint `SELECT * FROM users WHERE city = _` does **not** match the statement `SELECT * FROM users@users_pkey WHERE city = 'new york'` (which matches the fingerprint `SELECT * FROM users@users_pkey WHERE city = _`). As a result, you can use `information_schema.crdb_rewrite_inline_hints()` to remove inline hints:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Thank you!

Comment thread src/current/v26.1/cost-based-optimizer.md Outdated
{{site.data.alerts.callout_info}}
The `statement hints count` field shows the number of individual hints applied. A single row in `system.statement_hints` can contain multiple hints (such as an index hint and a join hint).
{{site.data.alerts.end}}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Let's skip documenting it for now.

@@ -39,15 +39,16 @@ The user requires the appropriate [privileges]({% link {{ page.version.version }

Parameter | Description
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how helpful this is, but just noting here that there are two "levels" to EXPLAIN parameters: "modes" and "flags". There has to be 1 mode, and then 0 or more flags for that mode.

Modes:

  • PLAN (the default if no modes are provided)
  • OPT
  • DISTSQL
  • DDL
  • VEC
  • DEBUG
  • GIST
  • FINGERPRINT (new)

Flags:

  • VERBOSE
  • TYPES
  • ENV
  • CATALOG
  • JSON
  • MEMO
  • SHAPE
  • VIZ
  • REDACT

It confuses things a little bit to document them all together, because they work a bit differently.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I will file this into a separate ticket.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/current/v26.1/show-statement-hints.md Outdated
craig Bot pushed a commit to cockroachdb/cockroach that referenced this pull request Jan 28, 2026
161545: docgen: update SHOW STATEMENT HINTS and EXPLAIN diagrams r=michae2 a=taroface

Updated the diagram for `SHOW STATEMENT HINTS` (exposing the `DETAILS` option). Diagram looks like:

<img width="547" height="274" alt="image" src="https://github.com/user-attachments/assets/1c66f39b-30b1-4dbf-a32b-893e4222db75" />

Also updated the `EXPLAIN` diagram to include the `FINGERPRINT` option:

<img width="605" height="453" alt="image" src="https://github.com/user-attachments/assets/1f9d9b27-b8b4-4c60-b1d2-3b4ad6aafb87" />

This is related to the docs PR cockroachdb/docs#20830

Epic: none
Release note: none
Release justification: non-production code change

Co-authored-by: Ryan Kuo <ryank@cockroachlabs.com>
craig Bot pushed a commit to cockroachdb/cockroach that referenced this pull request Jan 28, 2026
161545: docgen: update SHOW STATEMENT HINTS and EXPLAIN diagrams r=michae2 a=taroface

Updated the diagram for `SHOW STATEMENT HINTS` (exposing the `DETAILS` option). Diagram looks like:

<img width="547" height="274" alt="image" src="https://github.com/user-attachments/assets/1c66f39b-30b1-4dbf-a32b-893e4222db75" />

Also updated the `EXPLAIN` diagram to include the `FINGERPRINT` option:

<img width="605" height="453" alt="image" src="https://github.com/user-attachments/assets/1f9d9b27-b8b4-4c60-b1d2-3b4ad6aafb87" />

This is related to the docs PR cockroachdb/docs#20830

Epic: none
Release note: none
Release justification: non-production code change

Co-authored-by: Ryan Kuo <ryank@cockroachlabs.com>
@peachdawnleach peachdawnleach self-requested a review January 28, 2026 21:36
Copy link
Copy Markdown
Contributor

@peachdawnleach peachdawnleach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of small comments; otherwise LGTM. Very thorough and clear

Comment thread src/current/v26.1/cost-based-optimizer.md Outdated
-------|------|------------
`row_id` | `INT` | A unique ID.
`fingerprint` | `STRING` | The SQL statement fingerprint that the hint applies to.
`hint_type` | `STRING` | `rewrite_inline_hints`, indicating an injected hint.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand this one- is rewrite_inline_hints the only possible value here? If not, it might be good to make that more clear.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, eventually there will be other hint types! I clarified this but somewhat more indirectly.

@taroface taroface enabled auto-merge (squash) January 29, 2026 18:03
@taroface taroface merged commit 7519047 into main Jan 29, 2026
7 checks passed
@taroface taroface deleted the hint-injection branch January 29, 2026 18:12
craig Bot pushed a commit to cockroachdb/cockroach that referenced this pull request Jan 29, 2026
161545: docgen: update SHOW STATEMENT HINTS and EXPLAIN diagrams r=michae2 a=taroface

Updated the diagram for `SHOW STATEMENT HINTS` (exposing the `DETAILS` option). Diagram looks like:

<img width="547" height="274" alt="image" src="https://github.com/user-attachments/assets/1c66f39b-30b1-4dbf-a32b-893e4222db75" />

Also updated the `EXPLAIN` diagram to include the `FINGERPRINT` option:

<img width="605" height="453" alt="image" src="https://github.com/user-attachments/assets/1f9d9b27-b8b4-4c60-b1d2-3b4ad6aafb87" />

This is related to the docs PR cockroachdb/docs#20830

Epic: none
Release note: none
Release justification: non-production code change

Co-authored-by: Ryan Kuo <ryank@cockroachlabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants