BEGIN; BEGIN EXPLAIN select o_orderpriority, count(*) as order_count from orders where o_orderdate >= date '1996-05-01' and o_orderdate < cast(date '1996-05-01' + interval '3 month' as date) and exists ( select * from lineitem where l_orderkey = o_orderkey and l_commitdate < l_receiptdate ) group by o_orderpriority order by o_orderpriority; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=24548973.32..24548973.33 rows=1 width=16) Sort Key: orders.o_orderpriority -> HashAggregate (cost=24548973.30..24548973.31 rows=1 width=16) Group Key: orders.o_orderpriority -> 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=16610480.34..24525761.78 rows=4642305 width=16) -> HashAggregate (cost=16610480.34..24525761.78 rows=1 width=16) Group Key: orders.o_orderpriority -> Hash Semi Join (cost=16610480.34..24525761.78 rows=4642305 width=16) Hash Cond: (orders.o_orderkey = lineitem.l_orderkey) -> Bitmap Heap Scan on orders (cost=121679.33..2740584.58 rows=5734550 width=20) Recheck Cond: ((o_orderdate >= '1996-05-01'::date) AND (o_orderdate < '1996-08-01'::date)) -> Bitmap Index Scan on orders_o_orderdate_o_orderkey_idx (cost=0.00..120245.70 rows=5734550 width=0) Index Cond: ((o_orderdate >= '1996-05-01'::date) AND (o_orderdate < '1996-08-01'::date)) -> Hash (cost=13207343.15..13207343.15 rows=200012629 width=4) -> Bitmap Heap Scan on lineitem (cost=50007.29..13207343.15 rows=200012629 width=4) Recheck Cond: (l_commitdate < l_receiptdate) -> Bitmap Index Scan on lineitem_l_orderkey_idx_part1 (cost=0.00..4.13 rows=200012629 width=0) (17 rows) COMMIT; COMMIT