pingcap / pingcap/tidb

Useless partition pruning warning for `ANALYZE TABLE` statement

Open
#42,603 0 comments 0 reactions 1 assignee Claimed by @xuyifangreeneyes View on GitHub
component/statistics component/tablepartition severity/minor sig/planner type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

1. Warning about partition pruning for something that uses all partitions isn't really helpful as partition pruning wouldn't be used anyway.
2. Warning about missing statistics for a `ANALYZE TABLE` statement isn't really helpful either as this is what would populate the stats.

### 1. Minimal reproduce step (Required)

```sql
CREATE TABLE t1(c1 int)
partition by range(c1)
(partition p0 values less than (100),
partition p1 values less than maxvalue);
INSERT INTO t1 VALUES (1),(200),(400),(600);
ANALYZE TABLE t1;
```

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

```
sql> CREATE TABLE t1(c1 int)
-> partition by range(c1)
-> (partition p0 values less than (100),
-> partition p1 values less than maxvalue);
Query OK, 0 rows affected (0.2005 sec)

sql> INSERT INTO t1 VALUES (1),(200),(400),(600);
Query OK, 4 rows affected (0.0240 sec)

Records: 4 Duplicates: 0 Warnings: 0

sql> ANALYZE TABLE t1;
Query OK, 0 rows affected, 2 warnings (0.1893 sec)
Note (code 1105): Analyze use auto adjusted sample rate 1.000000 for table test.t1's partition p0
Note (code 1105): Analyze use auto adjusted sample rate 1.000000 for table test.t1's partition p1
```

### 3. What did you see instead (Required)

```
sql> CREATE TABLE t1(c1 int)
-> partition by range(c1)
-> (partition p0 values less than (100),
-> partition p1 values less than maxvalue);
Query OK, 0 rows affected (0.2005 sec)

sql> INSERT INTO t1 VALUES (1),(200),(400),(600);
Query OK, 4 rows affected (0.0240 sec)

Records: 4 Duplicates: 0 Warnings: 0

sql> ANALYZE TABLE t1;
Query OK, 0 rows affected, 4 warnings (0.1893 sec)
Warning (code 1105): disable dynamic pruning due to t1 has no global stats
Note (code 1105): Analyze use auto adjusted sample rate 1.000000 for table test.t1's partition p0
Warning (code 1105): disable dynamic pruning due to t1 has no global stats
Note (code 1105): Analyze use auto adjusted sample rate 1.000000 for table test.t1's partition p1
```
### 4. What is your TiDB version? (Required)

```
tidb_version(): Release Version: v6.6.0
Edition: Community
Git Commit Hash: f4ca0821fb96a2bdd37d2fb97eb26c07fc58d4e4
Git Branch: heads/refs/tags/v6.6.0
UTC Build Time: 2023-02-17 14:49:02
GoVersion: go1.19.5
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv
```

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.