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 ('SHIP', 'REG 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=984809.16..984809.16 rows=1 width=27) (actual time=25153.259..25153.259 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=1148188 read=215528 written=114 -> HashAggregate (cost=984809.14..984809.15 rows=1 width=27) (actual time=25153.196..25153.196 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=1148183 read=215528 written=114 -> Hash Join (cost=594310.27..979734.05 rows=290005 width=27) (actual time=11978.264..24827.243 rows=311519 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1148183 read=215528 written=114 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..376361.55 rows=290005 width=15) (actual time=0.183..12432.502 rows=311519 loops=1) Filter: ((l_shipmode = ANY ('{SHIP,"REG 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: 6885346 Buffers: shared hit=894704 read=214217 written=99 -> Hash (cost=405686.04..405686.04 rows=15089904 width=20) (actual time=11876.936..11876.936 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=253476 read=1311 written=15 -> Seq Scan on orders (cost=0.00..405686.04 rows=15089904 width=20) (actual time=0.024..5906.469 rows=15015000 loops=1) Buffers: shared hit=253476 read=1311 written=15 Planning time: 2.731 ms Execution time: 25162.315 ms (21 rows) COMMIT; COMMIT