> ## Documentation Index
> Fetch the complete documentation index at: https://cockroachlabs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# SHOW STATEMENT HINTS

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

The `SHOW STATEMENT HINTS` <InternalLink path="sql-statements">statement</InternalLink> lists the <InternalLink path="cost-based-optimizer#statement-hints">statement hints</InternalLink> that have been created for a specific SQL statement fingerprint using the `information_schema.crdb_rewrite_inline_hints()` and `information_schema.crdb_set_session_variable_hint()` <InternalLink path="functions-and-operators">built-in functions</InternalLink>.

## Required privileges

Users must have the <InternalLink path="security-reference/authorization#supported-privileges">`VIEWCLUSTERMETADATA`</InternalLink> privilege to run `SHOW STATEMENT HINTS`.

## Synopsis

<img src="https://mintcdn.com/cockroachlabs/yO0HPPIyye61-HYK/images/sql-diagrams/v26.3/show_statement_hints.svg?fit=max&auto=format&n=yO0HPPIyye61-HYK&q=85&s=180b919729e80c2bf1ff3de1aa3c208e" alt="show_statement_hints syntax diagram" style={{maxWidth: "100%", overflowX: "auto"}} width="567" height="251" data-path="images/sql-diagrams/v26.3/show_statement_hints.svg" />

## Parameters

| Parameter               | Description                                                                                                                                                                                                  |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `string_or_placeholder` | The SQL statement fingerprint to show hints for. This can be a string literal (such as `'SELECT * FROM users WHERE city = _'`) or a SQL parameter placeholder (such as `$1`) for use in prepared statements. |

### Options

| Option    | Value | Description                                       |
| --------- | ----- | ------------------------------------------------- |
| `DETAILS` | N/A   | Include hint-specific information in JSON format. |

## Response

The following fields are returned:

| Column        | Type          | Description                                                                                                                                                                                                                                                               |
| ------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `row_id`      | `INT`         | A unique ID.                                                                                                                                                                                                                                                              |
| `fingerprint` | `STRING`      | The SQL statement fingerprint that the hint applies to.                                                                                                                                                                                                                   |
| `hint_type`   | `STRING`      | Hint type. `REWRITE INLINE HINTS` indicates a rewritten inline hint. `SET VARIABLE` indicates a session variable override.                                                                                                                                                |
| `database`    | `STRING`      | The database the hint applies to. `NULL` if the hint applies to all databases.                                                                                                                                                                                            |
| `enabled`     | `BOOL`        | Whether the hint is enabled.                                                                                                                                                                                                                                              |
| `created_at`  | `TIMESTAMPTZ` | The timestamp when the hint was created.                                                                                                                                                                                                                                  |
| `details`     | `JSONB`       | When the [`DETAILS`](#options) option is specified, hint-specific information in JSON format. For `REWRITE INLINE HINTS`, this includes the donor SQL fingerprint with hints that will be applied. For `SET VARIABLE`, this includes the session variable name and value. |

## Examples

### Show hints for a statement

To show all hints for a specific statement fingerprint:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW STATEMENT HINTS FOR $$ SELECT * FROM users WHERE city = _ $$;
```

```
        row_id        |            fingerprint             |      hint_type       | database | enabled |          created_at
----------------------+------------------------------------+----------------------+----------+---------+--------------------------------
  1143470380756697089 | SELECT * FROM users WHERE city = _ | REWRITE INLINE HINTS | NULL     | t       | 2026-01-21 21:11:06.782818+00
(1 row)
```

### Show hints with detailed information

To include hint-specific details in the output:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
SHOW STATEMENT HINTS FOR $$ SELECT * FROM users WHERE city = _ $$ WITH DETAILS;
```

```
        row_id        |            fingerprint             |      hint_type       | database | enabled |          created_at           |                              details
----------------------+------------------------------------+----------------------+----------+---------+-------------------------------+--------------------------------------------------------------------
  1143470380756697089 | SELECT * FROM users WHERE city = _ | REWRITE INLINE HINTS | NULL     | t       | 2026-01-21 21:11:06.782818+00 | {"donorSql": "SELECT * FROM users@users_city_idx WHERE city = _"}
(1 row)
```

This example shows a `REWRITE INLINE HINTS` type hint. For a `SET VARIABLE` hint, the details would include the session variable name and value:

```
        row_id        |            fingerprint             | hint_type    | database | enabled |          created_at           |                       details
----------------------+------------------------------------+--------------+----------+---------+-------------------------------+------------------------------------------------------
  1167741942826958849 | SELECT * FROM users WHERE city = _ | SET VARIABLE | NULL     | t       | 2026-04-17 14:42:39.7001+00   | {"variableName": "vectorize", "variableValue": "on"}
(1 row)
```

## See also

* <InternalLink path="cost-based-optimizer#statement-hints">Statement hints</InternalLink>
* <InternalLink path="table-expressions#force-index-selection">Index hints</InternalLink>
* <InternalLink path="cost-based-optimizer#join-hints">Join hints</InternalLink>
* <InternalLink path="sql-statements">SQL Statements</InternalLink>
