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

pesudo statistics of empty table #25239

Open
qw4990 opened this issue Jun 8, 2021 · 2 comments
Open

pesudo statistics of empty table #25239

qw4990 opened this issue Jun 8, 2021 · 2 comments
Assignees
Labels
component/statistics severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@qw4990
Copy link
Contributor

qw4990 commented Jun 8, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE `t` (
  `a` int(11) DEFAULT NULL,
  KEY `a` (`a`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY HASH( `a` )
PARTITIONS 4;

insert into t values (1), (2), (3);
analyze table t;
desc select * from t;

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

The estRows of p0 should be 0 and the total estRows should be 3;

3. What did you see instead (Required)

mysql> desc select * from t;
+----------------------------+----------+-----------+-----------------------+--------------------------------+
| id                         | estRows  | task      | access object         | operator info                  |
+----------------------------+----------+-----------+-----------------------+--------------------------------+
| PartitionUnion_10          | 10003.00 | root      |                       |                                |
| ├─TableReader_12           | 10000.00 | root      |                       | data:TableFullScan_11          |
| │ └─TableFullScan_11       | 10000.00 | cop[tikv] | table:t, partition:p0 | keep order:false, stats:pseudo |
| ├─TableReader_16           | 1.00     | root      |                       | data:TableFullScan_15          |
| │ └─TableFullScan_15       | 1.00     | cop[tikv] | table:t, partition:p1 | keep order:false               |
| ├─TableReader_20           | 1.00     | root      |                       | data:TableFullScan_19          |
| │ └─TableFullScan_19       | 1.00     | cop[tikv] | table:t, partition:p2 | keep order:false               |
| └─TableReader_24           | 1.00     | root      |                       | data:TableFullScan_23          |
|   └─TableFullScan_23       | 1.00     | cop[tikv] | table:t, partition:p3 | keep order:false               |
+----------------------------+----------+-----------+-----------------------+--------------------------------+
9 rows in set (0.00 sec)

4. What is your TiDB version? (Required)

mysql> select version();
+----------------------------------------+
| version()                              |
+----------------------------------------+
| 5.7.25-TiDB-v5.2.0-alpha-10-g1aea274cc |
+----------------------------------------+
1 row in set (0.00 sec)

@qw4990 qw4990 added type/bug The issue is confirmed as a bug. sig/planner SIG: Planner component/statistics labels Jun 8, 2021
@rebelice rebelice self-assigned this Jun 10, 2021
@rebelice
Copy link
Contributor

It's not a bug about the partition table. It has the same behavior as the normal table.

MySQL [test]> create table t(a int, key(a));
Query OK, 0 rows affected (0.010 sec)

MySQL [test]> explain select * from t;
+-----------------------+----------+-----------+---------------+--------------------------------+
| id                    | estRows  | task      | access object | operator info                  |
+-----------------------+----------+-----------+---------------+--------------------------------+
| TableReader_5         | 10000.00 | root      |               | data:TableFullScan_4           |
| └─TableFullScan_4     | 10000.00 | cop[tikv] | table:t       | keep order:false, stats:pseudo |
+-----------------------+----------+-----------+---------------+--------------------------------+
2 rows in set (0.001 sec)

MySQL [test]> analyze table t;
Query OK, 0 rows affected (0.026 sec)

MySQL [test]> explain select * from t;
+-----------------------+----------+-----------+---------------+--------------------------------+
| id                    | estRows  | task      | access object | operator info                  |
+-----------------------+----------+-----------+---------------+--------------------------------+
| TableReader_5         | 10000.00 | root      |               | data:TableFullScan_4           |
| └─TableFullScan_4     | 10000.00 | cop[tikv] | table:t       | keep order:false, stats:pseudo |
+-----------------------+----------+-----------+---------------+--------------------------------+
2 rows in set (0.001 sec)

@rebelice rebelice changed the title wrong partition statistics of empty partitions pesudo statistics of empty table Jun 15, 2021
@yudongusa
Copy link

seems similar issue of #27083

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/statistics severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

3 participants