pingcap/tidb

confused and unnecessary double-projection in plans

Open

#20.734 geöffnet am 30. Okt. 2020

Auf GitHub ansehen
 (2 Kommentare) (0 Reaktionen) (1 zugewiesene Person)Go (6.186 Forks)batch import
help wantedsig/plannertype/enhancement

Repository-Metriken

Stars
 (40.090 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 14T 4h) (346 gemergte PRs in 30 T)

Beschreibung

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.

Contributor Guide