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=#DROP TABLE IF EXISTS t1; gaussdb=#DROP TABLE IF EXISTS t2; 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 ----------------------------------------------------------------------- Streaming (type: GATHER) (cost=28.03..28.94 rows=42 width=96) Node/s: All datanodes -> HashAggregate (cost=26.72..26.98 rows=42 width=96) Group By Key: t1.c1, t1.c2, t1.c3 -> Append (cost=0.00..26.52 rows=42 width=96) -> Seq Scan on t1 (cost=0.00..13.13 rows=20 width=96) -> Seq Scan on t2 (cost=0.00..13.13 rows=20 width=96) (7 rows)
In the preceding example, the output of the append operator is as follows.
Item |
Description |
---|---|
Append |
Operator name. |
Seq Scan on t1 |
Name of an operator that scans the t1 table in sequence. |
Seq Scan on t2 |
Name of an operator that scans the t2 table in sequence. |
Example 2: SQL statement with UNION ALL.
-- Execution result. gaussdb=#EXPLAIN SELECT * FROM t1 UNION ALL SELECT * FROM t2; QUERY PLAN ----------------------------------------------------------------------- Streaming (type: GATHER) (cost=1.62..28.70 rows=40 width=96) Node/s: All datanodes -> Result (cost=0.00..26.26 rows=40 width=96) -> Append (cost=0.00..26.26 rows=40 width=96) -> Seq Scan on t1 (cost=0.00..13.13 rows=20 width=96) -> Seq Scan on t2 (cost=0.00..13.13 rows=20 width=96) (6 rows) -- Drop the table. 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.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot