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 ('AIR', 'SHIP') 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=984970.31..984970.32 rows=1 width=27) (actual time=28296.722..28296.723 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=818367 read=545349 written=30 -> HashAggregate (cost=984970.29..984970.30 rows=1 width=27) (actual time=28296.637..28296.638 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=818362 read=545349 written=30 -> Hash Join (cost=594310.27..979897.29 rows=289886 width=27) (actual time=13119.495..27956.488 rows=311550 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=818362 read=545349 written=30 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..376528.51 rows=289886 width=15) (actual time=0.119..14387.545 rows=311550 loops=1) Filter: ((l_shipmode = ANY ('{AIR,SHIP}'::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: 6885315 Buffers: shared hit=580476 read=528445 written=23 -> Hash (cost=405686.04..405686.04 rows=15089904 width=20) (actual time=12933.964..12933.964 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=237883 read=16904 written=7 -> Seq Scan on orders (cost=0.00..405686.04 rows=15089904 width=20) (actual time=0.036..5909.781 rows=15015000 loops=1) Buffers: shared hit=237883 read=16904 written=7 Planning time: 4.477 ms Execution time: 28320.789 ms (21 rows) COMMIT; COMMIT