Skip to content

modify tidb_enable_historical_stats behavior #30821

@morgo

Description

@morgo

Enhancement

In #30646 we merged a new system variable: tidb_enable_historical_stats.

It uses the functions getTiDBTableValue() / setTiDBTableValue() to persist the saved values to the mysql.tidb table, but for new sysvars we don't need to do this. We should just rely on the built in saving/loading method.

The functions getTiDBTableValue() / setTiDBTableValue() are unfortunately required for existing variables related to garbage collection. This is because we do not have clear rules about upgrade/downgrade and need to support earlier versions of TiDB which read/write from these tables and do not use system variables.

We can not clean this up these functions until product management to define support versions/upgrade rules (cc @easonn7 ), but it does not have a use for new sysvars.

The advantage of using the built-in method is that the values are cached on each tidb-server in memory. If we add too many rows to the mysql.tidb table it will affect performance, because when SHOW VARIABLES is executed each value must be read one row at a time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/enhancementThe issue or PR belongs to an enhancement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions