You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
846 B
19 lines
846 B
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;
|
|
# Use indexPath in this query.
|
|
explain select count(1) from access_path_selection;
|
|
|