Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC-9968 sql: default sql.stats.statement_fingerprint.format_mask to use special flags #18514

Merged
merged 6 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/current/_includes/v23.2/ui/statement-fingerprints.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{% if page.cloud == true %}
{% capture link_prefix %}../{{site.current_cloud_version}}/{% endcapture %}
{% assign page_prefix = "" %}
{% else %}
{% assign link_prefix = "" %}
{% assign page_prefix = "ui-" %}
{% endif %}

### Example

See [View historical statement statistics and the sampled logical plan per fingerprint]({{ link_prefix }}crdb-internal.html#view-historical-statement-statistics-and-the-sampled-logical-plan-per-fingerprint).
florence-crl marked this conversation as resolved.
Show resolved Hide resolved

## SQL statement fingerprints

The **Statements** page displays SQL statement fingerprints.

A _statement fingerprint_ represents one or more SQL statements by replacing literal values (e.g., numbers and strings) with underscores (`_`). This can help you quickly identify frequently executed SQL statements and their latencies.

For multiple SQL statements to be represented by a fingerprint, they must be identical aside from their literal values and placeholders.

These SQL statements:

- `INSERT INTO new_order(product_id, customer_id, transaction_id) VALUES (380, 11, 11098)`
- `INSERT INTO new_order(product_id, customer_id, transaction_id) VALUES (192, 891, 20)`
- `INSERT INTO new_order(product_id, customer_id, transaction_id) VALUES (784, 452, 78)`

have the fingerprint `INSERT INTO new_order(product_id, customer_id, transaction_id) VALUES (_, _, __more1_10__)`

These SQL statements:

- `INSERT INTO new_order(product_id, customer_id, transaction_id) VALUES ($1, $2, 11098)`
- `INSERT INTO new_order(product_id, customer_id, transaction_id) VALUES ($1, $2, 300)`
- `INSERT INTO new_order(product_id, customer_id, transaction_id) VALUES ($1, $2, $3)`

have the fingerprint `INSERT INTO new_order(product_id, customer_id, transaction_id) VALUES ($1, $1, __more1_10__)`.

The following statement is not represented by either of the preceding fingerprints:

- `INSERT INTO new_order(product_id, customer_id, transaction_id) VALUES ($1, 11, 11098)`
florence-crl marked this conversation as resolved.
Show resolved Hide resolved

It is possible to see the same fingerprint listed multiple times in the following scenarios:

- Statements with this fingerprint were executed by more than one [`application_name`]({{ link_prefix }}show-vars.html#supported-variables).
- Statements with this fingerprint were executed both successfully and unsuccessfully.
43 changes: 43 additions & 0 deletions src/current/_includes/v24.1/ui/statement-fingerprints.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{% if page.cloud == true %}
{% capture link_prefix %}../{{site.current_cloud_version}}/{% endcapture %}
{% assign page_prefix = "" %}
{% else %}
{% assign link_prefix = "" %}
{% assign page_prefix = "ui-" %}
{% endif %}

### Example

See [View historical statement statistics and the sampled logical plan per fingerprint]({{ link_prefix }}crdb-internal.html#view-historical-statement-statistics-and-the-sampled-logical-plan-per-fingerprint).
florence-crl marked this conversation as resolved.
Show resolved Hide resolved

## SQL statement fingerprints

The **Statements** page displays SQL statement fingerprints.

A _statement fingerprint_ represents one or more SQL statements by replacing literal values (e.g., numbers and strings) and placeholders with underscores (`_`). Lists with only literals or placeholders and similar expressions are shortened to their first item followed by `__more__`.

Fingerprints can help you quickly identify frequently executed SQL statements and their latencies.

For multiple SQL statements to be represented by a fingerprint, they must be identical aside from their literal values and placeholders.

These SQL statements:

- `INSERT INTO new_order(product_id, customer_id, transaction_id) VALUES (380, 11, 11098)`
- `INSERT INTO new_order(product_id, customer_id, transaction_id) VALUES (192, 891, 20)`
- `INSERT INTO new_order(product_id, customer_id, transaction_id) VALUES (784, 452, 78)`
- `INSERT INTO new_order(product_id, customer_id, transaction_id) VALUES ($1, $2, 11098)`
- `INSERT INTO new_order(product_id, customer_id, transaction_id) VALUES ($1, $2, 300)`
- `INSERT INTO new_order(product_id, customer_id, transaction_id) VALUES ($1, 11, 11098)`
- `INSERT INTO new_order(product_id, customer_id, transaction_id) VALUES ($1, $2, $3)`

have the fingerprint `INSERT INTO new_order(product_id, customer_id, transaction_id) VALUES (_, __more__)`

The following statements are not represented by the preceding fingerprint:

- `INSERT INTO new_order(product_id, customer_id, transaction_id, item_count) VALUES (380, 11, 11098, 1)`;
- `INSERT INTO new_order(product_id, customer_id, transaction_id, item_count) VALUES (192, 891, 20, 2)`;
- `INSERT INTO new_order(product_id, customer_id, transaction_id, item_count) VALUES (784, 452, 78, 3)`;

Instead, they have the fingerprint `INSERT INTO new_order(product_id, customer_id, transaction_id, item_count) VALUES (_, __more__)`

It is possible to see the same fingerprint listed multiple times when statements with this fingerprint were executed by more than one [`application_name`]({{ link_prefix }}show-vars.html#supported-variables).
2 changes: 1 addition & 1 deletion src/current/_includes/v24.1/ui/statements-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Diagnostics | Activate and download [diagnostics](#diagnostics) for this fingerp
{{site.data.alerts.callout_info}}
To obtain the execution statistics, CockroachDB samples a percentage of the executions. If you see `no samples` displayed in the **Contention**, **Max Memory**, or **Network** columns, there are two possibilities:
- Your statement executed successfully but wasn't sampled because there were too few executions of the statement.
- Your statement has failed (the most likely case). You can confirm by clicking the statement and viewing the value for **Failed?**.
- Your statement has failed (the most likely case). You can confirm by clicking the statement and viewing the value for **Failure Count**.
{{site.data.alerts.end}}

To view statement details, click a SQL statement fingerprint in the **Statements** column to open the **Statement Fingerprint** page.
2 changes: 1 addition & 1 deletion src/current/cockroachcloud/statements-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ docs_area: manage

{% include {{version_prefix}}ui/statistics.md %}

{% include common/ui/statements-page.md %}
{% include {{version_prefix}}ui/statement-fingerprints.md %}

{% include {{version_prefix}}ui/statements-table.md %}

Expand Down
2 changes: 1 addition & 1 deletion src/current/v23.2/ui-statements-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ docs_area: reference.db_console

{% include {{ page.version.version }}/ui/statistics.md %}

{% include common/ui/statements-page.md %}
{% include {{ page.version.version }}/ui/statement-fingerprints.md %}

{% include {{ page.version.version }}/ui/statements-table.md %}

Expand Down
2 changes: 1 addition & 1 deletion src/current/v24.1/ui-statements-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ docs_area: reference.db_console

{% include {{ page.version.version }}/ui/statistics.md %}

{% include common/ui/statements-page.md %}
{% include {{ page.version.version }}/ui/statement-fingerprints.md %}

{% include {{ page.version.version }}/ui/statements-table.md %}

Expand Down
Loading