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 ('SHIP', 'MAIL') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1995-01-01' and l_receiptdate < date '1995-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=984910.08..984910.08 rows=1 width=27) (actual time=23797.998..23797.999 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=903610 read=463549 dirtied=509 written=1548 -> HashAggregate (cost=984910.06..984910.07 rows=1 width=27) (actual time=23797.936..23797.937 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=903605 read=463549 dirtied=509 written=1548 -> Hash Join (cost=593720.13..979814.27 rows=291188 width=27) (actual time=10969.361..23494.766 rows=311118 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=903605 read=463549 dirtied=509 written=1548 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..376994.94 rows=291188 width=15) (actual time=0.176..12161.290 rows=311118 loops=1) Filter: ((l_shipmode = ANY ('{SHIP,MAIL}'::bpchar[])) AND (l_receiptdate >= '1995-01-01'::date) AND (l_receiptdate < '1996-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6878747 Buffers: shared hit=702913 read=409704 dirtied=508 written=233 -> Hash (cost=405283.20..405283.20 rows=15074920 width=20) (actual time=10817.320..10817.320 rows=15000000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 892791kB Buffers: shared hit=200689 read=53845 dirtied=1 written=1315 -> Seq Scan on orders (cost=0.00..405283.20 rows=15074920 width=20) (actual time=0.019..5087.572 rows=15000000 loops=1) Buffers: shared hit=200689 read=53845 dirtied=1 written=1315 Planning time: 3.450 ms Execution time: 23810.319 ms (21 rows) COMMIT; COMMIT