Skip to content

DOC-13899 Product Change- PR #147439 - ui: surface SQL commenter query tags in insights #19897

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

florence-crl
Copy link
Contributor

@florence-crl florence-crl commented Jul 7, 2025

Fixes DOC-13899 DOC-13614

In include file insights.md, (1) added section for Query tags and (2) corrected SQL CPU Time column name.

Rendered preview

Copy link

github-actions bot commented Jul 7, 2025

Files changed:

Copy link

netlify bot commented Jul 7, 2025

Deploy Preview for cockroachdb-api-docs canceled.

Name Link
🔨 Latest commit f9a6f79
🔍 Latest deploy log https://app.netlify.com/projects/cockroachdb-api-docs/deploys/686f256035358d0008fbbbdb

Copy link

netlify bot commented Jul 7, 2025

Deploy Preview for cockroachdb-interactivetutorials-docs canceled.

Name Link
🔨 Latest commit f9a6f79
🔍 Latest deploy log https://app.netlify.com/projects/cockroachdb-interactivetutorials-docs/deploys/686f255f71dc220008aafa01

Copy link

netlify bot commented Jul 7, 2025

Netlify Preview

Name Link
🔨 Latest commit f9a6f79
🔍 Latest deploy log https://app.netlify.com/projects/cockroachdb-docs/deploys/686f255fc089bc000898fad1
😎 Deploy Preview https://deploy-preview-19897--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.

@florence-crl florence-crl requested review from mikeCRL, angles-n-daemons, kyle-a-wong and kevin-v-ngo and removed request for mikeCRL July 7, 2025 19:51
Copy link

@angles-n-daemons angles-n-daemons left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for adding this!

@florence-crl florence-crl requested a review from mikeCRL July 10, 2025 17:21
Copy link

@kevin-v-ngo kevin-v-ngo left a comment

Choose a reason for hiding this comment

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

Small nits regarding how SQL comments (that following the SQLcommenter specification) is an opt-in experience that can be used for application correlation.

@@ -122,15 +122,50 @@ Start Time (UTC) | The timestamp when the statement execution started.
Elapsed Time | The time that elapsed to complete the statement execution.
User Name | The name of the user that invoked the statement execution.
Application Name | The name specified by the [`application_name`]({{ link_prefix }}show-vars.html#supported-variables) session setting.
Query Tags | The [query tags](#query-tags) extracted from comments in the statement query. These tags provide application context and can be used to correlate query performance with client-side application state.

Choose a reason for hiding this comment

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

nit: can* help provide application if set

Note: Users don't get this out of the box. They need to instrument the comment in their query.

{%- endif %}
Full Scan | Whether the execution performed a full scan of the table.
Transaction Fingerprint ID | The ID of the transaction fingerprint for the statement execution.
Latest Transaction Execution ID | The ID of the transaction execution for the statement execution.

#### Query tags

{% include_cached new-in.html version="25.3.0" %} The **Query Tags** column displays SQLcommenter query tags for statement executions. These tags provide application context, such as the application name, user ID, or feature flags, embedded in SQL comments that follow the [SQLcommenter specification](https://google.github.io/sqlcommenter/spec/). This information helps correlate slow query performance with specific application states. The **Query Tags** column is available in the **Statement Executions** view's **Statement Insights** table but is hidden by default. To display it, use the **Columns** selector.

Choose a reason for hiding this comment

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

displays SQLcommenter query tags for statement executions

Can we say displays the comments embedded int he query as defined by the specification?

These tags provide application context, such as the application name, user ID, or feature flags, embedded in SQL comments that follow the

Users need to instrument this

Copy link
Contributor

@mikeCRL mikeCRL left a comment

Choose a reason for hiding this comment

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

Left some suggestions.

Also want to be sure you're aware of the various capitalizations of SQLcommenter: Google's blog uses Sqlcommenter, the repo uses sqlcommenter, and their docs are mixed, often using SQL commenter with a space. Not an easy call which one to use, and I can even see an argument for leaving as SQLcommenter.

{%- endif %}
Full Scan | Whether the execution performed a full scan of the table.
Transaction Fingerprint ID | The ID of the transaction fingerprint for the statement execution.
Latest Transaction Execution ID | The ID of the transaction execution for the statement execution.

#### Query tags

{% include_cached new-in.html version="25.3.0" %} The **Query Tags** column displays SQLcommenter query tags for statement executions. These tags provide application context, such as the application name, user ID, or feature flags, embedded in SQL comments that follow the [SQLcommenter specification](https://google.github.io/sqlcommenter/spec/). This information helps correlate slow query performance with specific application states. The **Query Tags** column is available in the **Statement Executions** view's **Statement Insights** table but is hidden by default. To display it, use the **Columns** selector.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{% include_cached new-in.html version="25.3.0" %} The **Query Tags** column displays SQLcommenter query tags for statement executions. These tags provide application context, such as the application name, user ID, or feature flags, embedded in SQL comments that follow the [SQLcommenter specification](https://google.github.io/sqlcommenter/spec/). This information helps correlate slow query performance with specific application states. The **Query Tags** column is available in the **Statement Executions** view's **Statement Insights** table but is hidden by default. To display it, use the **Columns** selector.
{% include_cached new-in.html version="25.3" %} The **Query Tags** column displays SQLcommenter query tags for statement executions. These tags provide application context, such as the application name, user ID, or feature flags, embedded in SQL comments that follow the [SQLcommenter specification](https://google.github.io/sqlcommenter/spec/). This information helps correlate slow query performance with specific application states. The **Query Tags** column is available in the **Statement Executions** view's **Statement Insights** table but is hidden by default. To display it, use the **Columns** selector.


Query tags are also included in the following locations:

- [**Statement Execution** details](#statement-execution-details) page
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- [**Statement Execution** details](#statement-execution-details) page
- The [**Statement Execution** details](#statement-execution-details) page

to match the structure of the other list items by using a more complete phrase


This feature is disabled by default. To enable it, set the [`sql.sqlcommenter.enabled` cluster setting]({{ link_prefix }}cluster-settings.html#setting-sql-sqlcommenter-enabled) to `true`.

For example:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be more specific about what the following instructions will do, e.g.

Suggested change
For example:
To test this functionality, you can generate a SQL query with a [Slow Execution](#slow-execution), then view it on the Insights page:

Comment on lines +150 to +156
1. Execute the following statements. Set `pg_sleep` to a value greater than the [`sql.insights.latency_threshold` cluster setting]({{ link_prefix }}cluster-settings.html#setting-sql-insights-latency-threshold) to generate a [Slow Execution](#slow-execution) insight.

{% include_cached copy-clipboard.html %}
~~~ sql
SET CLUSTER SETTING sql.sqlcommenter.enabled=true;
SELECT pg_sleep(2) /*db_driver='test_driver',db_framework='test_framework',db_backend='cockroachdb'*/;
~~~
Copy link
Contributor

Choose a reason for hiding this comment

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

A suggestion, for your consideration, to check the latency threshold first, and then split the other two statements into their own steps, explaining each.

Suggested change
1. Execute the following statements. Set `pg_sleep` to a value greater than the [`sql.insights.latency_threshold` cluster setting]({{ link_prefix }}cluster-settings.html#setting-sql-insights-latency-threshold) to generate a [Slow Execution](#slow-execution) insight.
{% include_cached copy-clipboard.html %}
~~~ sql
SET CLUSTER SETTING sql.sqlcommenter.enabled=true;
SELECT pg_sleep(2) /*db_driver='test_driver',db_framework='test_framework',db_backend='cockroachdb'*/;
~~~
1. Enable SQLcommenter query tagging:
{% include_cached copy-clipboard.html %}
~~~ sql
SET CLUSTER SETTING sql.sqlcommenter.enabled=true;
~~~
1. Check the value of cluster setting [`sql.insights.latency_threshold`]({{ link_prefix }}cluster-settings.html#setting-sql-insights-latency-threshold):
{% include_cached copy-clipboard.html %}
~~~ sql
SHOW CLUSTER SETTING sql.insights.latency_threshold;
~~~
1. Execute the following statement, using a `pg_sleep` value greater than the `latency_threshold`:
{% include_cached copy-clipboard.html %}
~~~ sql
SELECT pg_sleep(2) /*db_driver='test_driver',db_framework='test_framework',db_backend='cockroachdb'*/;
~~~

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.

5 participants