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', 'AIR') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1994-01-01' and l_receiptdate < date '1994-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=988852.98..988852.99 rows=1 width=27) (actual time=30613.821..30613.821 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=1229067 read=133227 written=3984 -> HashAggregate (cost=988852.96..988852.97 rows=1 width=27) (actual time=30613.737..30613.738 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=1229062 read=133227 written=3984 -> Hash Join (cost=596675.51..983771.84 rows=290350 width=27) (actual time=17165.377..30172.389 rows=312034 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1229062 read=133227 written=3984 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..378023.32 rows=290350 width=15) (actual time=0.132..12290.701 rows=312034 loops=1) Filter: ((l_shipmode = ANY ('{FOB,AIR}'::bpchar[])) AND (l_receiptdate >= '1994-01-01'::date) AND (l_receiptdate < '1995-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6884528 Buffers: shared hit=1051376 read=55109 written=3821 -> Hash (cost=407300.59..407300.59 rows=15149959 width=20) (actual time=16727.301..16727.301 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=177683 read=78118 written=163 -> Seq Scan on orders (cost=0.00..407300.59 rows=15149959 width=20) (actual time=0.028..6951.082 rows=15015000 loops=1) Buffers: shared hit=177683 read=78118 written=163 Planning time: 4.616 ms Execution time: 30653.294 ms (21 rows) COMMIT; COMMIT