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 ('AIR', '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=994876.28..994876.29 rows=1 width=27) (actual time=64127.990..64127.991 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=1060001 read=311441 written=23 -> HashAggregate (cost=994876.26..994876.27 rows=1 width=27) (actual time=64127.834..64127.836 rows=2 loops=1) Buffers: shared hit=1059996 read=311441 written=23 -> Hash Join (cost=600218.27..989738.72 rows=293574 width=27) (actual time=31281.858..63443.108 rows=312777 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1059996 read=311441 written=23 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.00..380346.26 rows=293574 width=15) (actual time=6.840..30684.377 rows=312777 loops=1) Filter: ((l_shipmode = ANY ('{AIR,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: 6883838 Buffers: shared hit=927656 read=186458 written=23 -> Hash (cost=409719.23..409719.23 rows=15239923 width=20) (actual time=31255.211..31255.211 rows=15015000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 762481kB Buffers: shared hit=132337 read=124983 -> Seq Scan on orders (cost=0.00..409719.23 rows=15239923 width=20) (actual time=0.030..21650.937 rows=15015000 loops=1) Buffers: shared hit=132337 read=124983 Total runtime: 64317.917 ms (19 rows) COMMIT; COMMIT