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

global stats of partition table may be incorrect under dynamic prune mode #34730

Closed
chrysan opened this issue May 17, 2022 · 0 comments · Fixed by #34695
Closed

global stats of partition table may be incorrect under dynamic prune mode #34730

chrysan opened this issue May 17, 2022 · 0 comments · Fixed by #34695
Assignees
Labels

Comments

@chrysan
Copy link
Contributor

chrysan commented May 17, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t (a int, b int, c int) partition by range (a) (partition p0 values less than (10), partition p1 values less than (20));
insert into t values (1,1,1), (2,2,2), (11,11,11);
set tidb_partition_prune_mode=dynamic;
analyze table t partition p0 columns b with 1 topn, 1 buckets;
analyze table t partition p1 columns c with 1 topn, 1 buckets;
select * from t where b>1 and c>1;
show stats_histograms where table_name like "t";

2. What did you expect to see? (Required)

distinct count should be 3 for both columns b & c

+---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+
| Db_name | Table_name | Partition_name | Column_name | Is_index | Update_time         | Distinct_count | Null_count | Avg_col_size | Correlation |
+---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+
| test    | t          | global         | b           |        0 | 2022-05-17 14:44:33 |              3 |          0 |            8 |           0 |
| test    | t          | global         | c           |        0 | 2022-05-17 14:44:33 |              3 |          0 |            8 |           0 |
+---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+

3. What did you see instead (Required)

distinct count is incorrect for both columns b & c, generate global stats ignoring the missing column stats.

+---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+
| Db_name | Table_name | Partition_name | Column_name | Is_index | Update_time         | Distinct_count | Null_count | Avg_col_size | Correlation |
+---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+
| test    | t          | global         | b           |        0 | 2022-05-17 14:41:52 |              2 |          0 |           17 |           0 |
| test    | t          | global         | c           |        0 | 2022-05-17 14:42:39 |              0 |          0 |           10 |           0 |

4. What is your TiDB version? (Required)

v6.0, master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant