Implement DXL Representation for VALUESSCAN [#147773843]
Postgres and thus (GPDB Planner) supports Values via an operator called ValueScan.
```
explain SELECT * FROM (VALUES (1, 'one'), (2, 'two'), (3, 'three')) AS t (num,letter);
QUERY PLAN
--------------------------------------------------------------
Values Scan on "*VALUES*" (cost=0.00..0.04 rows=1 width=36)
Optimizer status: legacy query optimizer
(2 rows)
```
However, inside Orca we expand each row in the Values list into a
Result node that projects constants.
Thus the above query with three rows having 2 columns is
represented as a plan by GPORCA as an append with three Result nodes.
Each of the Result nodes is a CTG with project elements.
```
explain SELECT * FROM (VALUES (1, 'one'), (2, 'two'), (3, 'three')) AS t (num,letter);
QUERY PLAN
-------------------------------------------------
Append (cost=0.00..0.00 rows=1 width=12)
-> Result (cost=0.00..0.00 rows=1 width=12)
-> Result (cost=0.00..0.00 rows=1 width=12)
-> Result (cost=0.00..0.00 rows=1 width=12)
Settings: optimizer=on
Optimizer status: PQO version 2.32.0
(6 rows)
```
This commit introduces a new value scan operator and instead of
generating multiple result node, ORCA will now generate a value scan
node. The resulting plan will look like:
```
QUERY PLAN
----------------------------------------------------------------------------------------------
Values Scan on "Values" (cost=0.00..0.44 rows=37000 width=4)
Optimizer status: PQO version 2.37.0
(2 rows)
```
This enhancement bring in significant performance improvement in total
runtime of the queries involving high number of constant values.
Signed-off-by: NEkta Khanna <ekhanna@pivotal.io>
Showing
想要评论请 注册 或 登录