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

unexpected partition pruning result #14539

Closed
XuHuaiyu opened this issue Jan 19, 2020 · 0 comments · Fixed by #14544
Closed

unexpected partition pruning result #14539

XuHuaiyu opened this issue Jan 19, 2020 · 0 comments · Fixed by #14544
Labels
severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@XuHuaiyu
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
CREATE TABLE `t` (
  `a` int(11) DEFAULT NULL,
  `b` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY RANGE COLUMNS(a) (
  PARTITION p0 VALUES LESS THAN (1),
  PARTITION p1 VALUES LESS THAN (10),
  PARTITION p2 VALUES LESS THAN (100)
);

desc select * from t where a = 11 and b = 1 or a = 12 and b = 1;
  1. What did you expect to see?
    Partition p0 and p1 will not be accessed.

  2. What did you see instead?
    All the partitions are accessed.

tidb> desc select * from t where a = 11 and b = 1 or a = 12 and b = 1;
+--------------------------+----------+-----------+------------------------------------------------------------------------------------+
| id                       | count    | task      | operator info                                                                      |
+--------------------------+----------+-----------+------------------------------------------------------------------------------------+
| Union_9                  | 24000.00 | root      |                                                                                    |
| ├─TableReader_12         | 8000.00  | root      | data:Selection_11                                                                  |
| │ └─Selection_11         | 8000.00  | cop[tikv] | or(and(eq(test.t.a, 11), eq(test.t.b, 1)), and(eq(test.t.a, 12), eq(test.t.b, 1))) |
| │   └─TableScan_10       | 10000.00 | cop[tikv] | table:t, partition:p0, range:[-inf,+inf], keep order:false, stats:pseudo           |
| ├─TableReader_15         | 8000.00  | root      | data:Selection_14                                                                  |
| │ └─Selection_14         | 8000.00  | cop[tikv] | or(and(eq(test.t.a, 11), eq(test.t.b, 1)), and(eq(test.t.a, 12), eq(test.t.b, 1))) |
| │   └─TableScan_13       | 10000.00 | cop[tikv] | table:t, partition:p1, range:[-inf,+inf], keep order:false, stats:pseudo           |
| └─TableReader_18         | 8000.00  | root      | data:Selection_17                                                                  |
|   └─Selection_17         | 8000.00  | cop[tikv] | or(and(eq(test.t.a, 11), eq(test.t.b, 1)), and(eq(test.t.a, 12), eq(test.t.b, 1))) |
|     └─TableScan_16       | 10000.00 | cop[tikv] | table:t, partition:p2, range:[-inf,+inf], keep order:false, stats:pseudo           |
+--------------------------+----------+-----------+------------------------------------------------------------------------------------+
10 rows in set (0.00 sec)
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
Release Version: v4.0.0-alpha-1373-g74bc00dfa
Git Commit Hash: 74bc00dfa953da06d8e5823d0acbf6bf1858a680
Git Branch: partition_prune
UTC Build Time: 2020-01-19 09:33:43
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants