quentusrex=# \i sql/view_index_union.sql CREATE TABLE CREATE INDEX CREATE TABLE CREATE INDEX INSERT 0 50000 INSERT 0 50000 CREATE VIEW QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------- Index Scan using named_a_idx on a (cost=0.41..4329.78 rows=51291 width=36) (actual time=0.078..33.854 rows=50000 loops=1) Total runtime: 36.226 ms (2 rows) QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------- Index Scan using named_b_idx on b (cost=0.41..4385.78 rows=51291 width=36) (actual time=0.036..27.166 rows=50000 loops=1) Total runtime: 29.418 ms (2 rows) QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------ Sort (cost=27371.05..27627.51 rows=102582 width=36) (actual time=435.566..535.213 rows=100000 loops=1) Sort Key: a.named Sort Method: external merge Disk: 4576kB -> Unique (cost=14230.75..15000.12 rows=102582 width=36) (actual time=75.540..131.131 rows=100000 loops=1) -> Sort (cost=14230.75..14487.21 rows=102582 width=36) (actual time=75.539..102.016 rows=100000 loops=1) Sort Key: a.id, a.named Sort Method: external merge Disk: 4584kB -> Append (cost=0.00..2885.64 rows=102582 width=36) (actual time=0.005..22.103 rows=100000 loops=1) -> Seq Scan on a (cost=0.00..929.91 rows=51291 width=36) (actual time=0.005..6.389 rows=50000 loops=1) -> Seq Scan on b (cost=0.00..929.91 rows=51291 width=36) (actual time=0.003..5.811 rows=50000 loops=1) Total runtime: 541.763 ms (11 rows) QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------ Sort (cost=26345.23..26601.69 rows=102582 width=36) (actual time=435.116..534.755 rows=100000 loops=1) Sort Key: a.named Sort Method: external merge Disk: 4576kB -> Unique (cost=14230.75..15000.12 rows=102582 width=36) (actual time=75.025..130.706 rows=100000 loops=1) -> Sort (cost=14230.75..14487.21 rows=102582 width=36) (actual time=75.024..101.363 rows=100000 loops=1) Sort Key: a.id, a.named Sort Method: external merge Disk: 4584kB -> Append (cost=0.00..2885.64 rows=102582 width=36) (actual time=0.006..21.939 rows=100000 loops=1) -> Seq Scan on a (cost=0.00..929.91 rows=51291 width=36) (actual time=0.005..6.187 rows=50000 loops=1) -> Seq Scan on b (cost=0.00..929.91 rows=51291 width=36) (actual time=0.004..5.890 rows=50000 loops=1) Total runtime: 541.167 ms (11 rows) QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------- Unique (cost=21086.49..21855.86 rows=102582 width=36) (actual time=133.286..180.493 rows=100000 loops=1) -> Sort (cost=21086.49..21342.95 rows=102582 width=36) (actual time=133.285..157.196 rows=100000 loops=1) Sort Key: a.id, a.named Sort Method: external merge Disk: 4568kB -> Append (cost=0.41..9741.38 rows=102582 width=36) (actual time=0.025..62.696 rows=100000 loops=1) -> Index Scan using named_a_idx on a (cost=0.41..4329.78 rows=51291 width=36) (actual time=0.025..25.143 rows=50000 loops=1) -> Index Scan using named_b_idx on b (cost=0.41..4385.78 rows=51291 width=36) (actual time=0.027..27.052 rows=50000 loops=1) Total runtime: 185.968 ms (8 rows) DROP VIEW DROP TABLE DROP TABLE quentusrex=#