pingcap/tidb

Support Dumping Table Statistics With A SQL Statement

Open

#18 635 ouverte le 16 juil. 2020

Voir sur GitHub
 (9 commentaires) (0 réactions) (0 assignés)Go (6 186 forks)batch import
feature/acceptedhelp wantedtype/feature-request

Métriques du dépôt

Stars
 (40 090 stars)
Métriques de merge PR
 (Merge moyen 14j 4h) (346 PRs mergées en 30 j)

Description

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.

Guide contributeur