pingcap/tidb

confused and unnecessary double-projection in plans

Open

#20.734 aberto em 30 de out. de 2020

Ver no GitHub
 (2 comments) (0 reactions) (1 assignee)Go (6.186 forks)batch import
help wantedsig/plannertype/enhancement

Métricas do repositório

Stars
 (40.090 stars)
Métricas de merge de PR
 (Mesclagem média 14d 4h) (346 fundiu PRs em 30d)

Description

Development Task

mysql> create table t (a int, b int, index(a));
Query OK, 0 rows affected (0.03 sec)

mysql> explain select b from t order by a limit 5;
+------------------------------------+---------+-----------+---------------------+-----------------------------------+
| id                                 | estRows | task      | access object       | operator info                     |
+------------------------------------+---------+-----------+---------------------+-----------------------------------+
| Projection_7                       | 5.00    | root      |                     | test.t.b                          |
| └─Projection_23                    | 5.00    | root      |                     | test.t.a, test.t.b                |
|   └─IndexLookUp_22                 | 5.00    | root      |                     | limit embedded(offset:0, count:5) |
|     ├─Limit_21(Build)              | 5.00    | cop[tikv] |                     | offset:0, count:5                 |
|     │ └─IndexFullScan_19           | 5.00    | cop[tikv] | table:t, index:a(a) | keep order:true, stats:pseudo     |
|     └─TableRowIDScan_20(Probe)     | 5.00    | cop[tikv] | table:t             | keep order:false, stats:pseudo    |
+------------------------------------+---------+-----------+---------------------+-----------------------------------+
6 rows in set (0.00 sec)

As shown above, the double-projection is confused and unnecessary, so it's better to merge them into one.

Guia do colaborador