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

get wrong NDV when to merge global stats without async #57264

Closed
hawkingrei opened this issue Nov 11, 2024 · 1 comment
Closed

get wrong NDV when to merge global stats without async #57264

hawkingrei opened this issue Nov 11, 2024 · 1 comment
Assignees
Labels
affects-6.5 This bug affects the 6.5.x(LTS) versions. severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@hawkingrei
Copy link
Member

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE `t1` (
  `emp_id` int(11) NOT NULL,
  `emp_name` varchar(25) NOT NULL,
  `salary` int(11) NOT NULL,
  `dept_id` int(11) NOT NULL,
  PRIMARY KEY (`emp_id`) /*T![clustered_index] NONCLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY RANGE (`emp_id`)
(PARTITION `p0` VALUES LESS THAN (1000),
 PARTITION `p1` VALUES LESS THAN (4000),
 PARTITION `p2` VALUES LESS THAN (12000),
 PARTITION `p3` VALUES LESS THAN (16000),
 PARTITION `p4` VALUES LESS THAN (20000),
 PARTITION `p5` VALUES LESS THAN (25000),
 PARTITION `p6` VALUES LESS THAN (30000),
 PARTITION `p7` VALUES LESS THAN (35000),
 PARTITION `p8` VALUES LESS THAN (40000),
 PARTITION `p9` VALUES LESS THAN (45000),
 PARTITION `p10` VALUES LESS THAN (50000),
 PARTITION `p11` VALUES LESS THAN (55000),
 PARTITION `p12` VALUES LESS THAN (65000),
 PARTITION `p13` VALUES LESS THAN (75000),
 PARTITION `p14` VALUES LESS THAN (85000),
 PARTITION `p15` VALUES LESS THAN (95000),
 PARTITION `p16` VALUES LESS THAN (105000),
 PARTITION `p17` VALUES LESS THAN (115000),
 PARTITION `p18` VALUES LESS THAN (125000),
 PARTITION `pmax` VALUES LESS THAN (MAXVALUE));

set cte_max_recursion_depth = 1000000000;
insert into
    employees3 WITH RECURSIVE EmployeeGenerator AS (
        SELECT
            101 AS emp_id,
            'Emp00001' AS emp_name,
            FLOOR(RAND() * (150000 - 50000) + 50000) AS salary,
            FLOOR(RAND() * 3 + 1) AS dept_id
        UNION
        ALL
        SELECT
            emp_id + 1,
            CONCAT('Emp', LPAD(CAST(emp_id - 100 AS CHAR), 5, '0')),
            FLOOR(RAND() * (150000 - 50000) + 50000),
            FLOOR(RAND() * 3 + 1)
        FROM
            EmployeeGenerator
        WHERE
            emp_id < 20100
    )
SELECT
    *
FROM
    EmployeeGenerator;



analyze table employees3 partition p12;
show stats_histograms where table_name='employees3' and Column_name='PRIMARY'

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

it should be not zero.

3. What did you see instead (Required)

image

4. What is your TiDB version? (Required)

@hawkingrei
Copy link
Member Author

It has been fixed by #57269

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.5 This bug affects the 6.5.x(LTS) versions. severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

1 participant