Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TopN statistics are collected unnecessarily for non-skewed values on small tables #53111

Open
terry1purcell opened this issue May 8, 2024 · 0 comments · May be fixed by #53035
Open

TopN statistics are collected unnecessarily for non-skewed values on small tables #53111

terry1purcell opened this issue May 8, 2024 · 0 comments · May be fixed by #53035

Comments

@terry1purcell
Copy link
Contributor

Enhancement

Current ANALYZE will collect by default the top 500 values for an interesting column (indexed column or predicate column). For tables that are sampled, then there is pruning logic to remove statistics that are not skewed. For tables that are NOT sampled (smaller tables) - the pruning logic is not invoked.

Below shows an example where values are collected with a count of 1 - which are not skewed.

tidb> show stats_topn;
+---------+------------+----------------+-------------+----------+------------+-------+
| Db_name | Table_name | Partition_name | Column_name | Is_index | Value      | Count |
+---------+------------+----------------+-------------+----------+------------+-------+
| test    | t2         |                | a           |        0 | 73         |    16 |
| test    | t2         |                | a           |        0 | 74         |    16 |
| test    | t2         |                | a           |        0 | 75         |    16 |
| test    | t2         |                | a           |        0 | 76         |    16 |
......
| test    | t2         |                | a           |        0 | 101        |     1 |
| test    | t2         |                | a           |        0 | 102        |     1 |
| test    | t2         |                | a           |        0 | 103        |     1 |
| test    | t2         |                | a           |        0 | 104        |     1 |
......
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant