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

range info in explain is inconsistent for full range #9231

Closed
eurekaka opened this issue Jan 31, 2019 · 3 comments
Closed

range info in explain is inconsistent for full range #9231

eurekaka opened this issue Jan 31, 2019 · 3 comments
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@eurekaka
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
mysql> create table t(a int, b int, index idx_b(b));
Query OK, 0 rows affected (0.01 sec)

mysql> explain select * from t;
+-------------------+----------+------+------------------------------------------------------------+
| id                | count    | task | operator info                                              |
+-------------------+----------+------+------------------------------------------------------------+
| TableReader_5     | 10000.00 | root | data:TableScan_4                                           |
| └─TableScan_4     | 10000.00 | cop  | table:t, range:[-inf,+inf], keep order:false, stats:pseudo |
+-------------------+----------+------+------------------------------------------------------------+
2 rows in set (0.00 sec)

mysql> explain select b from t use index(idx_b);
+-------------------+----------+------+---------------------------------------------------------------------+
| id                | count    | task | operator info                                                       |
+-------------------+----------+------+---------------------------------------------------------------------+
| IndexReader_5     | 10000.00 | root | index:IndexScan_4                                                   |
| └─IndexScan_4     | 10000.00 | cop  | table:t, index:b, range:[NULL,+inf], keep order:false, stats:pseudo |
+-------------------+----------+------+---------------------------------------------------------------------+
2 rows in set (0.00 sec)
  1. What did you expect to see?

Range info in both explain should be [Null, +inf]

  1. What did you see instead?

Range info for table scan is [-inf, +inf], which is wrong because the table scan is a full range table scan.

  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: v3.0.0-beta-25-gb3bdc5d79
Git Commit Hash: b3bdc5d797467f2548fb1bcd59092686ad3238f5
Git Branch: master
UTC Build Time: 2019-01-31 03:05:58
GoVersion: go version go1.11.1 darwin/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
@eurekaka eurekaka added type/bug The issue is confirmed as a bug. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. sig/planner SIG: Planner labels Jan 31, 2019
@eurekaka
Copy link
Contributor Author

This issue is related with #8588, we can fix them together. Another related issue is #8058.

@zz-jason
Copy link
Member

Since TiDB 4.0, we use TableFullScan or IndexFullScan to indicate that the query is performing a full range scan, the range representation is not a problem any more:

TiDB(root@127.0.0.1:test) > explain select * from t;
+-----------------------+----------+-----------+-----------------------------------------+
| id                    | estRows  | task      | operator info                           |
+-----------------------+----------+-----------+-----------------------------------------+
| TableReader_5         | 10000.00 | root      | data:TableFullScan_4                    |
| └─TableFullScan_4     | 10000.00 | cop[tikv] | table:t, keep order:false, stats:pseudo |
+-----------------------+----------+-----------+-----------------------------------------+
2 rows in set (0.01 sec)

TiDB(root@127.0.0.1:test) > explain select b from t use index(idx_b);
+-----------------------+----------+-----------+--------------------------------------------------+
| id                    | estRows  | task      | operator info                                    |
+-----------------------+----------+-----------+--------------------------------------------------+
| IndexReader_5         | 10000.00 | root      | index:IndexFullScan_4                            |
| └─IndexFullScan_4     | 10000.00 | cop[tikv] | table:t, index:b, keep order:false, stats:pseudo |
+-----------------------+----------+-----------+--------------------------------------------------+
2 rows in set (0.00 sec)

@zz-jason
Copy link
Member

thanks to @LittleFall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

2 participants