-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
incorrect plan produced by cascades planner when range is empty #6933
Labels
Comments
zz-jason
added
type/enhancement
The issue or PR belongs to an enhancement.
help wanted
Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
status/TODO
sig/planner
SIG: Planner
labels
Jun 28, 2018
We have a related optimization here. Doesn't it work? |
zz-jason
removed
the
help wanted
Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
label
Aug 27, 2018
@shenli It works but not enough. It's range may become nil in future optimization. |
confirmed that this issue has been improved: TiDB(root@127.0.0.1:test) > desc select * from t where a>5 and a<3;
+-------------+---------+------+---------------+
| id | estRows | task | operator info |
+-------------+---------+------+---------------+
| TableDual_5 | 0.00 | root | rows:0 |
+-------------+---------+------+---------------+
1 row in set (0.00 sec) |
But the execution plan is incorrect when cascades planner is enabled: TiDB(root@127.0.0.1:test) > set @@tidb_enable_cascades_planner = 1;
Query OK, 0 rows affected (0.00 sec)
TiDB(root@127.0.0.1:test) > desc select * from t where a>5 and a<3;
+------------------------+---------+-----------+--------------------------------------------------+
| id | estRows | task | operator info |
+------------------------+---------+-----------+--------------------------------------------------+
| IndexReader_14 | 8000.00 | root | index:IndexFullScan_15 |
| └─IndexFullScan_15 | 0.00 | cop[tikv] | table:t, index:a, keep order:false, stats:pseudo |
+------------------------+---------+-----------+--------------------------------------------------+
2 rows in set (0.00 sec) |
zz-jason
changed the title
use TableDual when the access range is empty
incorrect plan produced by cascades planner when range is empty
Mar 17, 2020
zz-jason
added
type/bug
The issue is confirmed as a bug.
and removed
status/TODO
type/enhancement
The issue or PR belongs to an enhancement.
labels
Mar 17, 2020
confirm it has been supported: tidb(127.0.0.1:4000) > desc select * from t where a>5 and a<3;
+-------------+---------+------+---------------+---------------+
| id | estRows | task | access object | operator info |
+-------------+---------+------+---------------+---------------+
| TableDual_5 | 0.00 | root | | rows:0 |
+-------------+---------+------+---------------+---------------+
1 row in set (0.00 sec) |
Please edit this comment to complete the following informationNot a bug
Duplicate bug
BugNote: Make Sure that 'component', and 'severity' labels are added 1. Root Cause Analysis (RCA)2. Symptom3. All Trigger Conditions4. Workaround (optional)5. Affected versions6. Fixed versions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Let's say we have the following table:
The following query leads to an empty range, which indicates no data will be read from the storage:
We can replace the whole operator DAG with a
TableDual
to further reduce the execution overhead.For further optimization, we can add a rule which operates on
TableDual
to remove the unnecessary execution overhead. For example, we can replace an inner join with aTableDual
when one of its child is aTableDual
, that is to say, the following DAG can be optimized to a singleTableDual
operator as well:The text was updated successfully, but these errors were encountered: