pingcap / tidb

TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://www.pingcap.com/tidb-serverless/
https://pingcap.com
Apache License 2.0
36.94k stars 5.81k forks source link

Support to export historical statistics #18745

Open qw4990 opened 4 years ago

qw4990 commented 4 years ago

Feature Request

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

There are some cases that when we(developer) get the wrong execution plan, statistics have been updated by auto-analyze or users without intention, which makes it harder to reproduce the plan and locate the reason.

Describe the feature you'd like:

Support to export historical statistics. There is already an API that can do this, but it has a strict limitation that the specified time cannot be earlier tikv_gc_run_interval minutes than the current time. (The default value of tikv_gc_run_interval is 10 minutes) This limitation makes this API hard to be used in realistic cases.

It's better to design a new way to implement this feature.

Teachability, Documentation, Adoption, Migration Strategy:

Export statistics in TiDB

qw4990 commented 4 years ago

We can use this feature(https://github.com/pingcap/tidb/issues/18117) to remove the limitation.

SunRunAway commented 4 years ago

I reopened this issue because extra works will be needed after #18117 is finished. 1) an interface to let users dump historical statistics according to a timestamp 2) a default GC time for the statistics tables.

qw4990 commented 2 years ago

The design doc(Chinese version) designed by @An-DJ and the work items: