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 ('AIR', 'TRUCK') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1997-01-01' and l_receiptdate < date '1997-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Sort (cost=3059045.50..3059045.50 rows=1 width=27) (actual time=33676.574..33676.575 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=596706 read=739122 written=199 -> HashAggregate (cost=3059045.48..3059045.49 rows=1 width=27) (actual time=33676.526..33676.527 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=596701 read=739122 written=199 -> Hash Join (cost=598445.50..3053978.91 rows=289518 width=27) (actual time=9556.931..33346.759 rows=311193 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=596701 read=739122 written=199 -> Seq Scan on lineitem (cost=0.00..2446485.98 rows=289518 width=15) (actual time=0.031..23413.922 rows=311193 loops=1) Filter: ((l_shipmode = ANY ('{AIR,TRUCK}'::bpchar[])) AND (l_commitdate < l_receiptdate) AND (l_shipdate < l_commitdate) AND (l_receiptdate >= '1997-01-01'::date) AND (l_receiptdate < '1998-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 59674345 Buffers: shared hit=433538 read=645722 -> Hash (cost=408509.11..408509.11 rows=15194911 width=20) (actual time=9480.015..9480.015 rows=15000000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 892791kB Buffers: shared hit=163160 read=93400 written=199 -> Seq Scan on orders (cost=0.00..408509.11 rows=15194911 width=20) (actual time=0.013..4632.020 rows=15000000 loops=1) Buffers: shared hit=163160 read=93400 written=199 Planning time: 2.193 ms Execution time: 33693.126 ms (21 rows) COMMIT; COMMIT