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', 'SHIP') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1996-01-01' and l_receiptdate < date '1996-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=989720.81..989720.82 rows=1 width=27) (actual time=21868.934..21868.934 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=1142648 read=219238 dirtied=336 written=4397 -> HashAggregate (cost=989720.79..989720.80 rows=1 width=27) (actual time=21868.877..21868.878 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=1142643 read=219238 dirtied=336 written=4397 -> Hash Join (cost=596675.51..984586.82 rows=293370 width=27) (actual time=10937.166..21584.140 rows=312403 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1142643 read=219238 dirtied=336 written=4397 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..378743.93 rows=293370 width=15) (actual time=0.086..10351.476 rows=312403 loops=1) Filter: ((l_shipmode = ANY ('{FOB,SHIP}'::bpchar[])) AND (l_receiptdate >= '1996-01-01'::date) AND (l_receiptdate < '1997-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6884159 Buffers: shared hit=932964 read=173113 dirtied=83 written=4266 -> Hash (cost=407300.59..407300.59 rows=15149959 width=20) (actual time=10830.028..10830.028 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=209676 read=46125 dirtied=253 written=131 -> Seq Scan on orders (cost=0.00..407300.59 rows=15149959 width=20) (actual time=0.019..5385.448 rows=15015000 loops=1) Buffers: shared hit=209676 read=46125 dirtied=253 written=131 Planning time: 3.215 ms Execution time: 21874.339 ms (21 rows) COMMIT; COMMIT