Files
tidb/cmd/explaintest/t/access_path_selection.test
Mingcong Han 2a155f4eaf planner: use ExtraHandleColumn as PK when generating TablePath (#11959)
* use ExtraHandleColumn as PK

* fix fmt

* move unittest to explaintest
2019-09-02 17:03:06 +08:00

18 lines
763 B
Plaintext

CREATE TABLE `access_path_selection` (
`a` int,
`b` int,
KEY `IDX_a` (`a`),
KEY `IDX_b` (`b`),
KEY `IDX_ab` (`a`, `b`)
);
explain select a from access_path_selection where a < 3;
# In this query, IDX_ab is better than IDX_a.
# The reason is that we have to do double scan if we use IDX_a since it doesn't contain column b.
explain select a, b from access_path_selection where a < 3;
# In this query, IDX_ab can't be used, so IDX_b is the best.
explain select a, b from access_path_selection where b < 3;
explain select a, b from access_path_selection where a < 3 and b < 3;
# _tidb_rowid should also be considered as PK.
explain select a, b from access_path_selection where a > 10 order by _tidb_rowid;
explain select max(_tidb_rowid) from access_path_selection;