pingcap/tidb

Support Dumping Table Statistics With A SQL Statement

Open

#18.635 geöffnet am 16. Juli 2020

Auf GitHub ansehen
 (9 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Go (6.186 Forks)batch import
feature/acceptedhelp wantedtype/feature-request

Repository-Metriken

Stars
 (40.090 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 14T 4h) (346 gemergte PRs in 30 T)

Beschreibung

Feature Request

Is your feature request related to a problem? Please describe:

For now we can only dump statistics via HTTP API(Introduction to Statistics):

curl http://${tidb-server-ip}:${tidb-server-status-port}/stats/dump/${db_name}/${table_name} > ${table_name}.stats.json

The problem is:

  • There is no privilege check on HTTP API
  • For some use cases, it's not easy to use compared with SQL statements

Describe the feature you'd like:

Support a SQL statement do dump the statistics into a file.

Things need to consider:

  • How to dump stats to a file located on the client-side?
  • How does this SQL statement cooperate with the LOAD STATS command?

Describe alternatives you've considered:

N/A

Teachability, Documentation, Adoption, Migration Strategy:

  • This simplifies documentation since examples can be shown assuming the user has an existing connection to TiDB. i.e. the variables ${tidb-server-ip} and ${tidb-server-status-port} might be confusing. From where they are, there may also be a firewall restricting HTTP API access (but allowing mysql port)

  • This could optionally be integrated to dumpling as a flag to preserve stats. This would help in cases where support works with customers to help reproduce issues.

Contributor Guide