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 ('FOB', 'MAIL') 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=3034912.34..3034912.34 rows=1 width=27) (actual time=34091.400..34091.401 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=742014 read=583265 dirtied=253 written=1 -> HashAggregate (cost=3034912.32..3034912.33 rows=1 width=27) (actual time=34091.344..34091.345 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=742009 read=583265 dirtied=253 written=1 -> Hash Join (cost=593719.70..3029877.08 rows=287728 width=27) (actual time=9423.038..33762.980 rows=310988 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=742009 read=583265 dirtied=253 written=1 -> Seq Scan on lineitem (cost=0.00..2427165.88 rows=287728 width=15) (actual time=0.217..24008.657 rows=310988 loops=1) Filter: ((l_shipmode = ANY ('{FOB,MAIL}'::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: 59735233 Buffers: shared hit=554413 read=516324 written=1 -> Hash (cost=405283.20..405283.20 rows=15074920 width=20) (actual time=9346.209..9346.209 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=187593 read=66941 dirtied=253 -> Seq Scan on orders (cost=0.00..405283.20 rows=15074920 width=20) (actual time=0.010..4539.898 rows=15015000 loops=1) Buffers: shared hit=187593 read=66941 dirtied=253 Planning time: 2.185 ms Execution time: 34105.496 ms (21 rows) COMMIT; COMMIT