Skip to content

sql: make it easier to inspect keys #61625

@awoods187

Description

@awoods187

In 21.1, we've added capabilities to identify contended keys. In #61507 we discuss making views of contended keys, but even with that information, it can be hard to parse the keys:

 SELECT * from tpcc.contended_keys;
  database_name | schema_name | name |                         key                          | num_contention_events
----------------+-------------+------+------------------------------------------------------+------------------------
  system        | public      | jobs | \227\211\375\010\337\316\243"\223\200\001\210        |                   127
  system        | public      | jobs | \227\211\375\010\337\316\243"\311\200\001\210        |                   127
  system        | public      | jobs | \227\211\375\010\337\316\243+\331\000\001\210        |                   127
  system        | public      | jobs | \227\211\375\010\337\316\243,\015\000\001\210        |                   127
  system        | public      | jobs | \227\211\375\010\337\316\243\030\354\000\001\212\211 |                   127

We need to make a function that makes it easy to parse these keys.

The crdb_internal.pretty_key is not currently super helpful either:

 SELECT DISTINCT
         database_name,
         schema_name,
         name,
         crdb_internal.pretty_key(key, 0),
         num_contention_events
    FROM crdb_internal.cluster_contention_events,
         crdb_internal.tables,
         crdb_internal.table_indexes
   WHERE crdb_internal.cluster_contention_events.index_id
         = crdb_internal.table_indexes.index_id
     AND crdb_internal.cluster_contention_events.table_id
         = crdb_internal.tables.table_id
ORDER BY num_contention_events DESC;
  database_name | schema_name |    name     |                     crdb_internal.pretty_key                     | num_contention_events
----------------+-------------+-------------+------------------------------------------------------------------+------------------------
  system        | public      | jobs        | /15/1/639461742496350209/0                                       |                   127
  system        | public      | jobs        | /15/1/639456872164982785/0                                       |                   127
  system        | public      | jobs        | /15/1/639456872168521729/0                                       |                   127
  system        | public      | jobs        | /15/1/639456872320532481/0                                       |                   127
  system        | public      | jobs        | /15/1/639456872323940353/0                                       |                   127
  system        | public      | jobs        | /15/1/639456872480407553/0                                       |                   127

Epic CRDB-6567

Jira issue: CRDB-2979

Metadata

Metadata

Assignees

Labels

C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)X-staleno-issue-activity

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions