Result
Sometimes a node just needs to return a result computed by a statement:
EXPLAIN ANALYZE SELECT 1; QUERY PLAN ---------- Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.003..0.005 rows=1 loops=1) Total runtime: 0.038 ms
Result nodes are basically quick pass-through nodes when individual values are being operated on, instead of sets of rows. They can be used to collapse and therefore optimize sections of a WHERE
clause that can be computed once:
EXPLAIN ANALYZE SELECT * FROM customers WHERE customerid=(SELECT min(customerid) FROM customers)+1; QUERY PLAN ---------- Index Scan using customers_pkey on customers (cost=0.06..8.33 rows=1 width=268) (actual time=0.085..0.088 rows=1 loops=1) Index Cond: (customerid = ($1 + 1)) InitPlan 2 (returns $1) -> Result (cost=0.05..0.06 rows=1 width=0) (actual time=0.061..0.062 rows=1 loops=1) InitPlan 1 (returns $0) -> Limit (cost...