April 2018
Intermediate to advanced
508 pages
15h 22m
English
Like Unique, Append is another node type that's less popular than it used to be. In earlier PostgreSQL versions, Append nodes were used to produce some types of UNION merges. As of PostgreSQL 8.4, most of these are done by the versatile HashAggregate instead:
EXPLAIN ANALYZE SELECT * FROM customers WHERE state='MA' UNION SELECT * FROM customers WHERE state='MD';
QUERY PLAN
----------
HashAggregate (cost=1476.06..1480.07 rows=401 width=268) (actual time=25.847..27.104 rows=401 loops=1)
-> Append (cost=0.00..1456.01 rows=401 width=268) (actual time=0.031..22.559 rows=401 loops=1)
-> Seq Scan on customers (cost=0.00..726.00 rows=214 width=268) (actual time=0.027..10.800 rows=214 loops=1)
Filter: ((state)::text = 'MA'::text)
-> Seq ...Read now
Unlock full access