pingcap / pingcap/tidb

planner: distinguish `analyzed empty table` and `un-analyzed table` in statistics

Open
#42,213 0 comments 0 reactions 0 assignees View on GitHub
component/statistics sig/planner type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Enhancement
Now the planner cannot distinguish `analyzed empty table` and `un-analyzed table` in statistics, and uses `pesudo-stats` for these tables, which may lead to sub-optimal plans.

For example, when joining an empty table with a large table, if the planner uses `pesudo-stats` for the empty table, then it thinks this empty table `has` 10000 rows and may select a `MergeJoin` or `HashJoin` for this query, which needs to scan the large table.

But if the planner knows the empty table has 0 rows correctly, it can use it as a driver table and select `IndexJoin` for this query.

![2544bf72-3976-4d94-aa11-bd1f8dc3187a](https://user-images.githubusercontent.com/7499936/224957738-66b10d93-d217-46fa-a950-72b9f6359523.jpeg)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.