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 ('REG AIR', 'MAIL') 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=986518.83..986518.84 rows=1 width=27) (actual time=22989.363..22989.363 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=955233 read=416398 dirtied=754 written=2535 -> HashAggregate (cost=986518.81..986518.82 rows=1 width=27) (actual time=22989.301..22989.302 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=955228 read=416398 dirtied=754 written=2535 -> Hash Join (cost=594902.76..981494.84 rows=287084 width=27) (actual time=10922.865..22700.551 rows=310594 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=955228 read=416398 dirtied=754 written=2535 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..377621.14 rows=287084 width=15) (actual time=0.183..11228.961 rows=310594 loops=1) Filter: ((l_shipmode = ANY ('{"REG AIR",MAIL}'::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: 6879085 Buffers: shared hit=760298 read=356284 dirtied=754 written=506 -> Hash (cost=406090.48..406090.48 rows=15104948 width=20) (actual time=10813.946..10813.946 rows=15000000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 892791kB Buffers: shared hit=194927 read=60114 written=2029 -> Seq Scan on orders (cost=0.00..406090.48 rows=15104948 width=20) (actual time=0.019..5599.677 rows=15000000 loops=1) Buffers: shared hit=194927 read=60114 written=2029 Planning time: 2.885 ms Execution time: 23024.816 ms (21 rows) COMMIT; COMMIT