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', 'AIR') 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=984128.23..984128.23 rows=1 width=27) (actual time=78280.428..78280.428 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=1048619 read=318415 written=74 -> HashAggregate (cost=984128.21..984128.22 rows=1 width=27) (actual time=78280.320..78280.320 rows=2 loops=1) Buffers: shared hit=1048614 read=318415 written=74 -> Hash Join (cost=593719.70..979039.35 rows=290792 width=27) (actual time=23489.808..77489.818 rows=312831 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1048614 read=318415 written=74 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.00..376232.40 rows=290792 width=15) (actual time=0.331..52365.584 rows=312831 loops=1) Filter: ((l_shipmode = ANY ('{MAIL,AIR}'::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: 6884371 Buffers: shared hit=795156 read=317336 written=73 -> Hash (cost=405283.20..405283.20 rows=15074920 width=20) (actual time=23479.612..23479.612 rows=15015000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 762481kB Buffers: shared hit=253455 read=1079 written=1 -> Seq Scan on orders (cost=0.00..405283.20 rows=15074920 width=20) (actual time=0.035..14448.996 rows=15015000 loops=1) Buffers: shared hit=253455 read=1079 written=1 Total runtime: 78449.850 ms (19 rows) COMMIT; COMMIT