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 '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=983042.63..983042.63 rows=1 width=27) (actual time=28700.899..28700.900 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=938773 read=424190 dirtied=106 written=88 -> HashAggregate (cost=983042.61..983042.62 rows=1 width=27) (actual time=28700.821..28700.822 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=938768 read=424190 dirtied=106 written=88 -> Hash Join (cost=593129.99..977969.46 rows=289894 width=27) (actual time=11786.256..28287.849 rows=312242 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=938768 read=424190 dirtied=106 written=88 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..375780.71 rows=289894 width=15) (actual time=0.274..16093.391 rows=312242 loops=1) Filter: ((l_shipmode = ANY ('{MAIL,AIR}'::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: 6884941 Buffers: shared hit=727197 read=381477 written=88 -> Hash (cost=404880.36..404880.36 rows=15059936 width=20) (actual time=11664.823..11664.823 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=211568 read=42713 dirtied=106 -> Seq Scan on orders (cost=0.00..404880.36 rows=15059936 width=20) (actual time=0.023..5496.079 rows=15015000 loops=1) Buffers: shared hit=211568 read=42713 dirtied=106 Planning time: 4.558 ms Execution time: 28706.552 ms (21 rows) COMMIT; COMMIT