Improve backup and restore of statistics #29628
Labels
component/br
This issue is related to BR of TiDB.
type/enhancement
The issue or PR belongs to an enhancement.
Enhancement
The statistics docs has information about how to export and import table statistics.
The br docs on backup of the mysql schema say the statistics related tables are never restored.
The FAQ entry on this says that backup of statistics is disabled in 4.0.10 and up and that you should run
ANALYZE
after doing a restore.Looking in the code shows that
DumpStatsToJSON
is called.tidb/br/pkg/backup/schema.go
Lines 113 to 117 in 4c929c5
Running the following results in statistics in a backup:
BACKUP SCHEMA test TO '/tmp/test_backup_001';
So in the
backupmeta.json
for each schema there is astats
key that holds a base64 encoded JSON that has the same format as the output of the stats dump as described in the statistics docs.Things that should be answered/fixed:
backupmeta.json
is not created by default and because it is stored as base64 encoded JSON as part of another JSON structure.a. Can we make this easier?
b. We should probably document this.
LOAD STATS
to accept abackupmeta.json
orbackupmeta
file?The text was updated successfully, but these errors were encountered: