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

column stats don't follow the lazy-load behavior after analyzing the table twice #42073

Closed
xuyifangreeneyes opened this issue Mar 9, 2023 · 0 comments · Fixed by #42076
Closed
Labels
affects-6.3 affects-6.4 affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-6.6 component/statistics severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@xuyifangreeneyes
Copy link
Contributor

xuyifangreeneyes commented Mar 9, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

use test;
create table t(a int, b int);
insert into t values (1,2), (3,4), (5,6), (7,8);
analyze table t;
show stats_histograms;
analyze table t;
show stats_histograms;

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

Stats of a and b are all evicted since the optimizer doesn't use stats of a or b(column stats are laze-load).

3. What did you see instead (Required)

After the second analyze, stats of a and b are all loaded, which doesn't follow the stats lazy-load behavior.

mysql> analyze table t;
Query OK, 0 rows affected, 1 warning (0.03 sec)

mysql> show stats_histograms;
+---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+-------------+-----------------+----------------+----------------+---------------+
| Db_name | Table_name | Partition_name | Column_name | Is_index | Update_time         | Distinct_count | Null_count | Avg_col_size | Correlation | Load_status | Total_mem_usage | Hist_mem_usage | Topn_mem_usage | Cms_mem_usage |
+---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+-------------+-----------------+----------------+----------------+---------------+
| test    | t          |                | a           |        0 | 2023-03-09 19:50:11 |              4 |          0 |            1 |           1 | allEvicted  |               0 |              0 |              0 |             0 |
| test    | t          |                | b           |        0 | 2023-03-09 19:50:11 |              4 |          0 |            1 |           1 | allEvicted  |               0 |              0 |              0 |             0 |
+---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+-------------+-----------------+----------------+----------------+---------------+
2 rows in set (0.03 sec)

mysql> analyze table t;
Query OK, 0 rows affected, 1 warning (0.04 sec)

mysql> show stats_histograms;
+---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+-------------+-----------------+----------------+----------------+---------------+
| Db_name | Table_name | Partition_name | Column_name | Is_index | Update_time         | Distinct_count | Null_count | Avg_col_size | Correlation | Load_status | Total_mem_usage | Hist_mem_usage | Topn_mem_usage | Cms_mem_usage |
+---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+-------------+-----------------+----------------+----------------+---------------+
| test    | t          |                | a           |        0 | 2023-03-09 19:50:22 |              4 |          0 |            1 |           1 | allLoaded   |             196 |              0 |            196 |             0 |
| test    | t          |                | b           |        0 | 2023-03-09 19:50:22 |              4 |          0 |            1 |           1 | allLoaded   |             196 |              0 |            196 |             0 |
+---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+-------------+-----------------+----------------+----------------+---------------+
2 rows in set (0.00 sec)

4. What is your TiDB version? (Required)

master

@xuyifangreeneyes xuyifangreeneyes added type/bug The issue is confirmed as a bug. sig/planner SIG: Planner component/statistics labels Mar 9, 2023
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 labels Mar 9, 2023
@xuyifangreeneyes xuyifangreeneyes added affects-6.3 affects-6.4 affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-6.6 and removed may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-6.1 may-affects-6.5 labels Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.3 affects-6.4 affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-6.6 component/statistics severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants