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 ('FOB', 'REG AIR') 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=993662.22..993662.23 rows=1 width=27) (actual time=44974.304..44974.305 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=538509 read=832262 dirtied=1178 written=51305 -> HashAggregate (cost=993662.20..993662.21 rows=1 width=27) (actual time=44974.180..44974.181 rows=2 loops=1) Buffers: shared hit=538504 read=832262 dirtied=1178 written=51305 -> Hash Join (cost=599035.64..988502.00 rows=294869 width=27) (actual time=18067.396..44362.195 rows=312758 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=538504 read=832262 dirtied=1178 written=51305 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.00..380251.70 rows=294869 width=15) (actual time=3.164..24898.498 rows=312758 loops=1) Filter: ((l_shipmode = ANY ('{FOB,"REG AIR"}'::bpchar[])) AND (l_receiptdate >= '1993-01-01'::date) AND (l_receiptdate < '1994-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6883931 Buffers: shared hit=281688 read=832262 dirtied=1178 written=51305 -> Hash (cost=408911.95..408911.95 rows=15209895 width=20) (actual time=18046.541..18046.541 rows=15015000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 762481kB Buffers: shared hit=256813 -> Seq Scan on orders (cost=0.00..408911.95 rows=15209895 width=20) (actual time=0.032..7628.540 rows=15015000 loops=1) Buffers: shared hit=256813 Total runtime: 45148.195 ms (19 rows) COMMIT; COMMIT