BEGIN; BEGIN EXPLAIN select l_shipmode, sum(case when o_orderpriority = '1-URGENT' or o_orderpriority = '2-HIGH' then 1 else 0 end) as high_line_count, sum(case when o_orderpriority <> '1-URGENT' and o_orderpriority <> '2-HIGH' then 1 else 0 end) as low_line_count from orders, lineitem where o_orderkey = l_orderkey and l_shipmode in ('REG AIR', 'TRUCK') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1993-01-01' and l_receiptdate < date '1993-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=20477645.90..20477645.91 rows=1 width=27) Sort Key: lineitem.l_shipmode -> HashAggregate (cost=20477645.88..20477645.89 rows=1 width=27) Group Key: lineitem.l_shipmode -> 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=6787517.49..20427290.40 rows=2877456 width=27) -> HashAggregate (cost=6787517.49..20427290.40 rows=1 width=27) Group Key: lineitem.l_shipmode -> Hash Join (cost=6787517.49..20427290.40 rows=2877456 width=27) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) -> Bitmap Heap Scan on lineitem (cost=723.49..12157996.20 rows=2877456 width=15) Recheck Cond: ((l_commitdate < l_receiptdate) AND (l_shipdate < l_commitdate)) Filter: ((l_shipmode = ANY ('{"REG AIR",TRUCK}'::bpchar[])) AND (l_receiptdate >= '1993-01-01'::date) AND (l_receiptdate < '1994-01-01 00:00:00'::timestamp without time zone)) -> Bitmap Index Scan on lineitem_l_orderkey_idx_part2 (cost=0.00..4.13 rows=66670876 width=0) -> Hash (cost=4032887.00..4032887.00 rows=150000000 width=20) -> Seq Scan on orders (cost=0.00..4032887.00 rows=150000000 width=20) (15 rows) COMMIT; COMMIT