pingcap/tidb

confused and unnecessary double-projection in plans

Open

#20 734 ouverte le 30 oct. 2020

Voir sur GitHub
 (2 commentaires) (0 réactions) (1 assigné)Go (6 186 forks)batch import
help wantedsig/plannertype/enhancement

Métriques du dépôt

Stars
 (40 090 stars)
Métriques de merge PR
 (Merge moyen 14j 4h) (346 PRs mergées en 30 j)

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.

Guide contributeur