Skip to content

planner: unexpected low out-of-range estimation on index stats #64572

@qw4990

Description

@qw4990

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Reach out me to get the internal plan replayer file.

See the case below, the estimation is extremely low:

Image

This issue was accidentally introduced by #55600.

Before this PR, for index out-of-range estimation, we'll just use the index stats directly.
After this PR, if it's a single-column predicate, we'll use its corresponding column Histogram, which seems a reasonable Improvement.
But the problem is that this column's NDV is small, all values are collected into TopN, so it has no Histogram, which leads to the extreme estimation.

Image Image Image

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

Before that PR, the estimation seems acceptable.
Image

3. What did you see instead (Required)

Extremely low estimation.

4. What is your TiDB version? (Required)

After #55600

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions