cockroachdb / cockroachdb/cockroach
Introduce method to track intent counts to SQL statements
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Is your feature request related to a problem? Please describe.**
There is currently no way to track intent counts to SQL statements. This has always been an issue. It has been difficult to troubleshoot intents, and the inability to easily see which statements are laying a lot of intents has made investigations much more lengthy and involved forever.
**Describe the solution you'd like**
This feature request is introduce improved observability into intents, specifically being able to track which statements are currently laying intents. It would be great to also include historical information on very high-intent queries (perhaps an insight). Whether this is best handled via a query, a DB console page, an Insight, or something else, I'm unsure.
**Describe alternatives you've considered**
The only "alternative" method is to run the following query:
```
SELECT *
FROM (
SELECT range_id, start_pretty, end_pretty, (crdb_internal.range_stats(start_key)->>'intent_count')::INT AS intent_count
FROM crdb_internal.ranges_no_leases)
WHERE intent_count != 0 ORDER BY intent_count DESC;
```
Problems with this:
1. The output isn't per SQL statement, it's per table ID. So we don't have per-statement tracking, and we can only track it to the table if we then take further steps to translate the table ID:
```
range_id | start_pretty | end_pretty | intent_count
-----------+--------------+------------+---------------
70 | /Table/104 | /Max | 10000
```
2. We don't recommend relying on the usage of `crdb_internal.ranges_no_leases` in production since this table is subject to change. This is in our docs: https://www.cockroachlabs.com/docs/stable/crdb-internal
Jira issue: CRDB-47935
Contributor guide
Assessment
This issue has not been assessed yet.