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

Closed
terry1purcell opened this issue May 8, 2024 · 1 comment · Fixed by #53035
Closed
Labels
type/enhancement The issue or PR belongs to an enhancement.

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 |
......
@elsa0520
Copy link
Contributor

Do we already support the pruning TopN logic in small table (sampled table) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
2 participants