== WITHOUT AGGREGATE PUSHDOWN == postgres=# explain analyze select count(*) from ft1, ft2; QUERY PLAN --------------------------------------------------------------------------------------------------------------------- Aggregate (cost=35144.50..35144.51 rows=1 width=8) (actual time=1716.935..1716.936 rows=1 loops=1) -> Foreign Scan (cost=100.00..32644.50 rows=1000000 width=0) (actual time=0.566..1623.846 rows=1000000 loops=1) Relations: (public.ft1) INNER JOIN (public.ft2) Planning time: 7.770 ms Execution time: 1717.127 ms (5 rows) postgres=# explain analyze select sum(ft2.c2) from ft1, ft2 group by ft1.c2; QUERY PLAN --------------------------------------------------------------------------------------------------------------------- HashAggregate (cost=37644.50..37646.50 rows=200 width=12) (actual time=2742.964..2742.967 rows=10 loops=1) Group Key: ft1.c2 -> Foreign Scan (cost=100.00..32644.50 rows=1000000 width=8) (actual time=0.726..2388.803 rows=1000000 loops=1) Relations: (public.ft1) INNER JOIN (public.ft2) Planning time: 2.383 ms Execution time: 2743.351 ms (6 rows) postgres=# explain analyze select sum(ft2.c2) from ft1, ft2 group by ft1.c2 having avg(ft2.c2) < 500; QUERY PLAN --------------------------------------------------------------------------------------------------------------------- HashAggregate (cost=40144.50..40147.00 rows=200 width=12) (actual time=2591.888..2591.899 rows=10 loops=1) Group Key: ft1.c2 Filter: (avg(ft2.c2) < '500'::numeric) -> Foreign Scan (cost=100.00..32644.50 rows=1000000 width=8) (actual time=0.721..2179.561 rows=1000000 loops=1) Relations: (public.ft1) INNER JOIN (public.ft2) Planning time: 1.442 ms Execution time: 2592.139 ms (7 rows) === WITH AGGREGATE PUSHDOWN === postgres=# explain analyze select count(*) from ft1, ft2; QUERY PLAN ------------------------------------------------------------------------------------------------------ Foreign Scan (cost=15144.50..15144.53 rows=1 width=8) (actual time=150.785..150.787 rows=1 loops=1) Relations: Aggregate on ((public.ft1) INNER JOIN (public.ft2)) Planning time: 6.978 ms Execution time: 151.193 ms (4 rows) postgres=# explain analyze select sum(ft2.c2) from ft1, ft2 group by ft1.c2; QUERY PLAN -------------------------------------------------------------------------------------------------------- Foreign Scan (cost=17644.50..17644.80 rows=1 width=12) (actual time=374.539..374.540 rows=10 loops=1) Relations: Aggregate on ((public.ft1) INNER JOIN (public.ft2)) Planning time: 2.652 ms Execution time: 374.770 ms (4 rows) postgres=# explain analyze select sum(ft2.c2) from ft1, ft2 group by ft1.c2 having avg(ft2.c2) < 500; QUERY PLAN -------------------------------------------------------------------------------------------------------- Foreign Scan (cost=20144.50..20144.82 rows=1 width=12) (actual time=432.854..432.856 rows=10 loops=1) Relations: Aggregate on ((public.ft1) INNER JOIN (public.ft2)) Planning time: 2.739 ms Execution time: 433.133 ms (4 rows)