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

planner: should use TableScan when use index() has no arguments #12033

Closed
francis0407 opened this issue Sep 5, 2019 · 0 comments · Fixed by #12037
Closed

planner: should use TableScan when use index() has no arguments #12033

francis0407 opened this issue Sep 5, 2019 · 0 comments · Fixed by #12037
Assignees
Labels
sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@francis0407
Copy link
Member

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
    If possible, provide a recipe for reproducing the error.
mysql> create table t(a int, b int primary key, index idx_a(a));
Query OK, 0 rows affected (0.03 sec)

mysql> explain select a from t use index();
  1. What did you expect to see?
    In MySQL, the query above chooses TableScan.
mysql> explain select a from t use index();
+----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+-------+
| id | select_type | table | partitions | type | possible_keys | key  | key_len | ref  | rows | filtered | Extra |
+----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+-------+
|  1 | SIMPLE      | t     | NULL       | ALL  | NULL          | NULL | NULL    | NULL |    1 |   100.00 | NULL  |
+----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+-------+
1 row in set, 1 warning (0.00 sec)

mysql> explain select a from t;
+----+-------------+-------+------------+-------+---------------+-------+---------+------+------+----------+-------------+
| id | select_type | table | partitions | type  | possible_keys | key   | key_len | ref  | rows | filtered | Extra       |
+----+-------------+-------+------------+-------+---------------+-------+---------+------+------+----------+-------------+
|  1 | SIMPLE      | t     | NULL       | index | NULL          | idx_a | 5       | NULL |    1 |   100.00 | Using index |
+----+-------------+-------+------------+-------+---------------+-------+---------+------+------+----------+-------------+
1 row in set, 1 warning (0.01 sec)
  1. What did you see instead?
mysql> explain select a from t use index();
+-------------------+----------+------+---------------------------------------------------------------------+
| id                | count    | task | operator info                                                       |
+-------------------+----------+------+---------------------------------------------------------------------+
| IndexReader_7     | 10000.00 | root | index:IndexScan_6                                                   |
| └─IndexScan_6     | 10000.00 | cop  | table:t, index:a, range:[NULL,+inf], keep order:false, stats:pseudo |
+-------------------+----------+------+---------------------------------------------------------------------+
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
mysql> select tidb_version();
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                                                            |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v4.0.0-alpha-198-g8810a9c
Git Commit Hash: 8810a9c167ad71c9a51e82e2a0411405d1862512
Git Branch: improve_skylineprune
UTC Build Time: 2019-09-04 10:23:18
GoVersion: go version go1.12.7 linux/amd64
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
@francis0407 francis0407 added type/bug The issue is confirmed as a bug. sig/planner SIG: Planner labels Sep 5, 2019
@francis0407 francis0407 self-assigned this Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

1 participant