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', 'RAIL') 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=990589.41..990589.42 rows=1 width=27) (actual time=52511.406..52511.406 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=1161735 read=210898 dirtied=300 written=96 -> HashAggregate (cost=990589.39..990589.40 rows=1 width=27) (actual time=52511.247..52511.248 rows=2 loops=1) Buffers: shared hit=1161730 read=210898 dirtied=300 written=96 -> Hash Join (cost=597265.22..985437.13 rows=294415 width=27) (actual time=22722.179..51870.744 rows=312558 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1161730 read=210898 dirtied=300 written=96 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.00..378971.44 rows=294415 width=15) (actual time=0.513..27927.613 rows=312558 loops=1) Filter: ((l_shipmode = ANY ('{MAIL,RAIL}'::bpchar[])) AND (l_receiptdate >= '1996-01-01'::date) AND (l_receiptdate < '1997-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6884024 Buffers: shared hit=969788 read=146783 dirtied=77 written=6 -> Hash (cost=407703.43..407703.43 rows=15164943 width=20) (actual time=22711.063..22711.063 rows=15015000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 762481kB Buffers: shared hit=191939 read=64115 dirtied=223 written=90 -> Seq Scan on orders (cost=0.00..407703.43 rows=15164943 width=20) (actual time=0.085..13680.963 rows=15015000 loops=1) Buffers: shared hit=191939 read=64115 dirtied=223 written=90 Total runtime: 52627.971 ms (19 rows) COMMIT; COMMIT