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', 'FOB') 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=3038186.07..3038186.07 rows=1 width=27) (actual time=33763.689..33763.689 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=887819 read=438771 dirtied=253 written=2 -> HashAggregate (cost=3038186.05..3038186.06 rows=1 width=27) (actual time=33763.639..33763.640 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=887814 read=438771 dirtied=253 written=2 -> Hash Join (cost=594309.84..3033048.40 rows=293580 width=27) (actual time=9333.154..33441.487 rows=312879 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=887814 read=438771 dirtied=253 written=2 -> Seq Scan on lineitem (cost=0.00..2429564.18 rows=293580 width=15) (actual time=0.081..23794.875 rows=312879 loops=1) Filter: ((l_shipmode = ANY ('{RAIL,FOB}'::bpchar[])) AND (l_commitdate < l_receiptdate) AND (l_shipdate < l_commitdate) AND (l_receiptdate >= '1993-01-01'::date) AND (l_receiptdate < '1994-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 59732947 Buffers: shared hit=658232 read=413563 written=1 -> Hash (cost=405686.04..405686.04 rows=15089904 width=20) (actual time=9278.656..9278.656 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=229579 read=25208 dirtied=253 written=1 -> Seq Scan on orders (cost=0.00..405686.04 rows=15089904 width=20) (actual time=0.015..4199.480 rows=15015000 loops=1) Buffers: shared hit=229579 read=25208 dirtied=253 written=1 Planning time: 2.562 ms Execution time: 33768.506 ms (21 rows) COMMIT; COMMIT