-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
use test;
create table t(a int, b int, c int) partition by range(a) (
partition p1 values less than (100),
partition p2 values less than (200),
partition pm values less than (MAXVALUE));
analyze table t;
explain select * from t where a between "123" and "199";
2. What did you expect to see? (Required)
unnecessary partitions would be pruned, like MySQL result:
+----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+-------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+-------------+
| 1 | SIMPLE | t | p2 | ALL | NULL | NULL | NULL | NULL | 1 | 100.00 | Using where |
+----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+-------------+
3. What did you see instead (Required)
All partitions would be visited.
If the number of partitions are large(e.g., in our online DB, a table has more than 2000+ partititions),the select performance is really poor.
+-------------------------+----------+-----------+---------------+--------------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+-------------------------+----------+-----------+---------------+--------------------------------------------------------------------------------+
| TableReader_7 | 8000.00 | root | partition:all | data:Selection_6 |
| └─Selection_6 | 8000.00 | cop[tikv] | | ge(cast(test.t.a, double BINARY), 123), le(cast(test.t.a, double BINARY), 199) |
| └─TableFullScan_5 | 10000.00 | cop[tikv] | table:t | keep order:false, stats:pseudo |
+-------------------------+----------+-----------+---------------+--------------------------------------------------------------------------------+
4. What is your TiDB version? (Required)
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v9.0.0-alpha-158-gba79f5078d-dirty
Edition: Community
Git Commit Hash: ba79f50
Git Branch: master
UTC Build Time: 2025-01-22 08:18:45
GoVersion: go1.23.5
Race Enabled: false
Check Table Before Drop: false
Store: unistore |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+