pingcap/tidb

Support Dumping Table Statistics With A SQL Statement

Open

#18,635 创建于 2020年7月16日

在 GitHub 查看
 (9 评论) (0 反应) (0 负责人)Go (6,186 fork)batch import
feature/acceptedhelp wantedtype/feature-request

仓库指标

Star
 (40,090 star)
PR 合并指标
 (平均合并 14天 4小时) (30 天内合并 346 个 PR)

描述

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.

贡献者指南