Append
Description
Append is used to append multiple relationship sets and process the linked list that contains one or more subplans.
Typical Scenarios
- SQL statements with UNION.
- SQL statements with UNION ALL.
Examples
Example 1: SQL statement with UNION.
-- Prepare data. gaussdb=# CREATE TABLE t1(c1 number, c2 number, c3 number); CREATE TABLE gaussdb=# INSERT INTO t1 VALUES(generate_series(1, 100), 2, 3); INSERT 0 100 gaussdb=# CREATE TABLE t2(c1 number, c2 number, c3 number); CREATE TABLE gaussdb=# INSERT INTO t2 VALUES(generate_series(1, 100), 2, 3); INSERT 0 100 -- Execution result. gaussdb=# EXPLAIN SELECT * FROM t1 UNION SELECT * FROM t2; QUERY PLAN ------------------------------------------------------------------ HashAggregate (cost=31.57..39.05 rows=748 width=85) Group By Key: t1.c1, t1.c2, t1.c3 -> Append (cost=0.00..25.96 rows=748 width=85) -> Seq Scan on t1 (cost=0.00..2.00 rows=100 width=15) -> Seq Scan on t2 (cost=0.00..16.48 rows=648 width=96) (5 rows)
Example 2: SQL statement with UNION ALL.
gaussdb=# EXPLAIN SELECT * FROM t1 UNION ALL SELECT * FROM t2; QUERY PLAN ----------------------------------------------------------------- Result (cost=0.00..4.00 rows=200 width=15) -> Append (cost=0.00..4.00 rows=200 width=15) -> Seq Scan on t1 (cost=0.00..2.00 rows=100 width=15) -> Seq Scan on t2 (cost=0.00..2.00 rows=100 width=15) (4 rows) -- Drop. gaussdb=# DROP TABLE t1,t2;
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.