1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
| // PK(varchar) 在 2.0 版本中强制使用索引查询 / PK(varchar) 需要 TiDB 分配 tidb_rowid 作为 handle id 使用
MySQL [order-tidb]> explain select count(*) from trip_order use index(`primary`);
+----------------+--------------+----------------+------+------------------------------------------------------------------------+----------+
| id | parents | children | task | operator info | count |
+----------------+--------------+----------------+------+------------------------------------------------------------------------+----------+
| IndexScan_16 | StreamAgg_8 | | cop | table:trip_order, index:order_id, range:[<nil>,+inf], keep order:false | 10000.00 |
| StreamAgg_8 | | IndexScan_16 | cop | , funcs:count(1) | 1.00 |
| IndexReader_18 | StreamAgg_17 | | root | index:StreamAgg_8 | 1.00 |
| StreamAgg_17 | | IndexReader_18 | root | , funcs:count(col_0) | 1.00 |
+----------------+--------------+----------------+------+------------------------------------------------------------------------+----------+
4 rows in set (0.01 sec)
// PK(int) 在 2.0 版本中强制使用索引查询 / PK(int) 等于 row handle id
MySQL [order-tidb]> explain select count(*) from trip_order use index();
+----------------+--------------+----------------+------+-------------------------------------------------------+----------+
| id | parents | children | task | operator info | count |
+----------------+--------------+----------------+------+-------------------------------------------------------+----------+
| TableScan_15 | StreamAgg_8 | | cop | table:trip_order, range:[-inf,+inf], keep order:false | 10000.00 |
| StreamAgg_8 | | TableScan_15 | cop | , funcs:count(1) | 1.00 |
| TableReader_17 | StreamAgg_16 | | root | data:StreamAgg_8 | 1.00 |
| StreamAgg_16 | | TableReader_17 | root | , funcs:count(col_0) | 1.00 |
+----------------+--------------+----------------+------+-------------------------------------------------------+----------+
4 rows in set (0.00 sec)
MySQL [order-tidb]> explain select count(*) from trip_order use index( );
+----------------+--------------+----------------+------+-------------------------------------------------------+----------+
| id | parents | children | task | operator info | count |
+----------------+--------------+----------------+------+-------------------------------------------------------+----------+
| TableScan_15 | StreamAgg_8 | | cop | table:trip_order, range:[-inf,+inf], keep order:false | 10000.00 |
| StreamAgg_8 | | TableScan_15 | cop | , funcs:count(1) | 1.00 |
| TableReader_17 | StreamAgg_16 | | root | data:StreamAgg_8 | 1.00 |
| StreamAgg_16 | | TableReader_17 | root | , funcs:count(col_0) | 1.00 |
+----------------+--------------+----------------+------+-------------------------------------------------------+----------+
4 rows in set (0.00 sec)
|