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

support PointGet plan when table has alias name #11149

Closed
zz-jason opened this issue Jul 9, 2019 · 1 comment · Fixed by #11270
Closed

support PointGet plan when table has alias name #11149

zz-jason opened this issue Jul 9, 2019 · 1 comment · Fixed by #11270
Assignees
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. sig/planner SIG: Planner type/enhancement The issue or PR belongs to an enhancement.

Comments

@zz-jason
Copy link
Member

zz-jason commented Jul 9, 2019

Feature Request

Is your feature request related to a problem? Please describe:

drop table if exists t;
create table t(a bigint, b bigint, c bigint, primary key(a, b));

If the table has no alias name, it can be executed with Point_Get plan:

TiDB(root@127.0.0.1:test) > desc select * from t where a = 1 and b = 1;
+-------------+-------+------+--------------------+
| id          | count | task | operator info      |
+-------------+-------+------+--------------------+
| Point_Get_1 | 1.00  | root | table:t, index:a b |
+-------------+-------+------+--------------------+
1 row in set (0.00 sec)

But if we add an alias name for the queried table, it can not be executed by Point_Get plan:

TiDB(root@127.0.0.1:test) > desc select * from t tmp where a = 1 and b = 1;
+-------------------+-------+------+------------------------------------------------------------------------+
| id                | count | task | operator info                                                          |
+-------------------+-------+------+------------------------------------------------------------------------+
| IndexLookUp_7     | 1.25  | root |                                                                        |
| ├─IndexScan_5     | 1.25  | cop  | table:tmp, index:a, b, range:[1 1,1 1], keep order:false, stats:pseudo |
| └─TableScan_6     | 1.25  | cop  | table:t, keep order:false, stats:pseudo                                |
+-------------------+-------+------+------------------------------------------------------------------------+
3 rows in set (0.00 sec)

Describe the feature you'd like:

Be able to use point get plan even when the table has an alias name.

Describe alternatives you've considered:

No

Teachability, Documentation, Adoption, Migration Strategy:

No

@zz-jason 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. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. sig/planner SIG: Planner labels Jul 9, 2019
@sduzh
Copy link
Contributor

sduzh commented Jul 15, 2019

while I am working on it, I found another bug: PointGet does not check the table name in where clause.

mysql> create table t(k int not null primary key);
Query OK, 0 rows affected (0.01 sec)
mysql> insert into t values(1),(2),(3);
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0
mysql> select * from t where xxxxxxx.k=1;
+---+
| k |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. sig/planner SIG: Planner type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants