BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) 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 ('RAIL', 'TRUCK') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1994-01-01' and l_receiptdate < date '1994-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Sort (cost=989533.47..989533.47 rows=1 width=27) (actual time=24548.242..24548.243 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=939932 read=425467 dirtied=554 written=7804 -> HashAggregate (cost=989533.45..989533.46 rows=1 width=27) (actual time=24548.178..24548.178 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=939927 read=425467 dirtied=554 written=7804 -> Hash Join (cost=596675.51..984466.72 rows=289527 width=27) (actual time=11211.224..24243.502 rows=311716 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=939927 read=425467 dirtied=554 written=7804 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..378743.93 rows=289527 width=15) (actual time=0.127..12524.257 rows=311716 loops=1) Filter: ((l_shipmode = ANY ('{RAIL,TRUCK}'::bpchar[])) AND (l_receiptdate >= '1994-01-01'::date) AND (l_receiptdate < '1995-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6884846 Buffers: shared hit=737131 read=372459 dirtied=554 written=7657 -> Hash (cost=407300.59..407300.59 rows=15149959 width=20) (actual time=10877.612..10877.612 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=202793 read=53008 written=147 -> Seq Scan on orders (cost=0.00..407300.59 rows=15149959 width=20) (actual time=0.025..5663.888 rows=15015000 loops=1) Buffers: shared hit=202793 read=53008 written=147 Planning time: 3.316 ms Execution time: 24572.093 ms (21 rows) COMMIT; COMMIT