Skip to content

unique key get wrong row count when to query the Null value  #56116

@hawkingrei

Description

@hawkingrei

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t2(id bigint(20) DEFAULT NULL, UNIQUE KEY index_on_id (id));
insert into t2 values (), (), ();
analyze table t2;
explain select count(*) from t2 where id is null;

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

StreamAgg_17 1.00 root  funcs:count(Column#5)->Column#3,
└─IndexReader_18 1.00 root  index:StreamAgg_9,
  └─StreamAgg_9 1.00 cop[tikv]  funcs:count(1)->Column#5,
    └─IndexRangeScan_16 3.00 cop[tikv] table:t2, index:index_on_id(id) range:[NULL,NULL], keep order:false,

3. What did you see instead (Required)

StreamAgg_17 1.00 root  funcs:count(Column#5)->Column#3,
└─IndexReader_18 1.00 root  index:StreamAgg_9,
  └─StreamAgg_9 1.00 cop[tikv]  funcs:count(1)->Column#5,
    └─IndexRangeScan_16 1.00 cop[tikv] table:t2, index:index_on_id(id) range:[NULL,NULL], keep order:false,

4. What is your TiDB version? (Required)

Metadata

Metadata

Assignees

Labels

affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.component/statisticsseverity/majorsig/plannerSIG: Plannertype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions