tidb_index_prof

command module
v0.0.0-...-99a9354 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2022 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

tidb_index_prof

Usage

./tidb_index_prof -u <dbname> -p <dbpass> -H host -P <port> -l <log level>

output: sql query summary in last 30minutes, how many times each index is used (will also output non used indexes) for more detail: https://docs.pingcap.com/tidb/dev/statement-summary-tables

Example

$ go build

$ cat sample.sql
create table t(a varchar(255) primary key, b varchar(255), c int, key b(b), key c(c));
insert into t values('a', 'b', 1);
insert into t values('aa', 'bb', 2);
insert into t values('aaa', 'bbbb', 3);
insert into t values('aaaaa', 'bbbbb', 4);
select * from t;
select * from t where a='a';
select * from t where a='aa';
select * from t where a='aaa' or c = 4;

$ ./tidb_index_prof | jq .
{
  "full_table_scan_samples": [
    {
      "digest_text": "select * from `t`",
      "digest": "e5796985ccafe2f71126ed6c0ac939ffa015a8c0744a24b7aee6d587103fd2f7",
      "table_names": [
        "test.t"
      ],
      "used_indexes": null,
      "count": 1,
      "first_seen": "2022-08-12T15:49:53Z",
      "last_seen": "2022-08-12T15:49:53Z"
    }
  ],
  "stat": {
    "t": {
      "t:PRIMARY": 3,
      "t:b": 0,
      "t:c": 1,
      "t:primary": 1
    }
  }
}

Documentation

Overview

tidb_index_prof usage: ./tidb_index_prof -u <username> -p <password> -H host -P <port> -l <log level> -db <dbname> output: sql query summary in last 30minutes, how many times each index is used (will also output non used indexes) for more detail: https://docs.pingcap.com/tidb/dev/statement-summary-tables

Example:

create table t(a varchar(255) primary key, b varchar(255), c int, key b(b), key c(c)); insert into t values('a', 'b', 1); insert into t values('aa', 'bb', 2); insert into t values('aaa', 'bbbb', 3); insert into t values('aaaaa', 'bbbbb', 4); select * from t; select * from t where a='a'; select * from t where a='aa'; select * from t where a='aaa' or c = 4;

$ ./tidb_index_prof | jq .

{
  "full_table_scan_samples": [
    {
      "digest_text": "select * from `t`",
      "digest": "e5796985ccafe2f71126ed6c0ac939ffa015a8c0744a24b7aee6d587103fd2f7",
      "table_names": [
        "test.t"
      ],
      "used_indexes": null,
      "count": 1,
      "first_seen": "2022-08-12T15:49:53Z",
      "last_seen": "2022-08-12T15:49:53Z"
    }
  ],
  "stat": {
    "t": {
      "t:PRIMARY": 3,
      "t:b": 0,
      "t:c": 1,
      "t:primary": 1
    }
  }
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL