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 ('MAIL', 'TRUCK') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1996-01-01' and l_receiptdate < date '1996-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=3056182.14..3056182.15 rows=1 width=27) (actual time=33851.614..33851.614 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=879233 read=455268 written=152 -> HashAggregate (cost=3056182.12..3056182.13 rows=1 width=27) (actual time=33851.559..33851.559 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=879228 read=455268 written=152 -> Hash Join (cost=597855.36..3051057.63 rows=292828 width=27) (actual time=9606.073..33525.625 rows=312624 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=879228 read=455268 written=152 -> Seq Scan on lineitem (cost=0.00..2444051.40 rows=292828 width=15) (actual time=0.177..23597.391 rows=312624 loops=1) Filter: ((l_shipmode = ANY ('{MAIL,TRUCK}'::bpchar[])) AND (l_commitdate < l_receiptdate) AND (l_shipdate < l_commitdate) AND (l_receiptdate >= '1996-01-01'::date) AND (l_receiptdate < '1997-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 59732370 Buffers: shared hit=667144 read=411042 written=2 -> Hash (cost=408106.27..408106.27 rows=15179927 width=20) (actual time=9532.219..9532.219 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=212081 read=44226 written=150 -> Seq Scan on orders (cost=0.00..408106.27 rows=15179927 width=20) (actual time=0.014..4406.173 rows=15015000 loops=1) Buffers: shared hit=212081 read=44226 written=150 Planning time: 3.062 ms Execution time: 33856.320 ms (21 rows) COMMIT; COMMIT