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', 'REG AIR') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1997-01-01' and l_receiptdate < date '1997-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=993790.48..993790.48 rows=1 width=27) (actual time=44773.232..44773.232 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=1085039 read=282327 written=1 -> HashAggregate (cost=993790.46..993790.47 rows=1 width=27) (actual time=44773.121..44773.121 rows=2 loops=1) Buffers: shared hit=1085034 read=282327 written=1 -> Hash Join (cost=599625.78..988708.18 rows=290416 width=27) (actual time=16888.612..44136.565 rows=311248 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1085034 read=282327 written=1 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.00..380006.90 rows=290416 width=15) (actual time=0.104..25784.091 rows=311248 loops=1) Filter: ((l_shipmode = ANY ('{MAIL,"REG AIR"}'::bpchar[])) AND (l_receiptdate >= '1997-01-01'::date) AND (l_receiptdate < '1998-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6885477 Buffers: shared hit=834529 read=275763 written=1 -> Hash (cost=409314.79..409314.79 rows=15224879 width=20) (actual time=16877.718..16877.718 rows=15015000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 762481kB Buffers: shared hit=250502 read=6564 -> Seq Scan on orders (cost=0.00..409314.79 rows=15224879 width=20) (actual time=0.037..8348.887 rows=15015000 loops=1) Buffers: shared hit=250502 read=6564 Total runtime: 44912.638 ms (19 rows) COMMIT; COMMIT