BEGIN; BEGIN EXPLAIN select c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, sum(l_quantity) from customer, orders, lineitem where o_orderkey in ( select l_orderkey from lineitem group by l_orderkey having sum(l_quantity) > 314 ) and c_custkey = o_custkey and o_orderkey = l_orderkey group by c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice order by o_totalprice desc, o_orderdate LIMIT 100; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=132026477.38..132026526.37 rows=100 width=39) -> GroupAggregate (cost=132026477.38..174583270.33 rows=86875298 width=39) Group Key: orders.o_totalprice, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey -> Remote Subquery Scan on all (datanode_1_1,datanode_2_1,datanode_3_1,datanode_4_1,datanode_5_1,datanode_6_1,datanode_7_1,datanode_8_1) (cost=132026477.38..172411387.88 rows=86875298 width=39) -> GroupAggregate (cost=132026477.38..172411387.88 rows=86875298 width=39) Group Key: orders.o_totalprice, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey -> Sort (cost=186242455.97..186459644.21 rows=86875298 width=39) Sort Key: orders.o_totalprice DESC, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey -> Hash Join (cost=132026477.38..172411387.88 rows=86875298 width=39) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) -> Seq Scan on lineitem (cost=0.00..16657556.88 rows=600037888 width=8) -> Hash (cost=131585341.22..131585341.22 rows=21717453 width=39) -> Hash Join (cost=122263096.53..131585341.22 rows=21717453 width=39) Hash Cond: (orders.o_orderkey = lineitem_1.l_orderkey) -> Hash Join (cost=690271.00..8345007.06 rows=43434906 width=35) Hash Cond: (orders.o_custkey = customer.c_custkey) -> Seq Scan on orders (cost=0.00..4032887.00 rows=150000000 width=16) -> Hash (cost=502771.00..502771.00 rows=15000000 width=23) -> Seq Scan on customer (cost=0.00..502771.00 rows=15000000 width=23) -> Hash (cost=119580615.87..119580615.87 rows=121429893 width=4) -> GroupAggregate (cost=112348159.12..118366316.94 rows=121429893 width=8) Group Key: lineitem_1.l_orderkey Filter: (sum(lineitem_1.l_quantity) > '314'::double precision) -> Sort (cost=112348159.12..113848253.84 rows=600037888 width=8) Sort Key: lineitem_1.l_orderkey -> Seq Scan on lineitem lineitem_1 (cost=0.00..16657556.88 rows=600037888 width=8) (26 rows) COMMIT; COMMIT