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 ('RAIL', 'TRUCK') 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=990414.95..990414.96 rows=1 width=27) (actual time=32461.966..32461.966 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=726238 read=650513 dirtied=448 written=76 -> HashAggregate (cost=990414.93..990414.94 rows=1 width=27) (actual time=32461.878..32461.880 rows=2 loops=1) Buffers: shared hit=726233 read=650513 dirtied=448 written=76 -> Hash Join (cost=597265.22..985253.25 rows=294953 width=27) (actual time=15604.442..31972.404 rows=312559 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=726233 read=650513 dirtied=448 written=76 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.00..378770.75 rows=294953 width=15) (actual time=0.136..15173.890 rows=312559 loops=1) Filter: ((l_shipmode = ANY ('{RAIL,TRUCK}'::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: 6884023 Buffers: shared hit=560214 read=560475 dirtied=168 written=10 -> Hash (cost=407703.43..407703.43 rows=15164943 width=20) (actual time=15593.179..15593.179 rows=15015000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 762481kB Buffers: shared hit=166016 read=90038 dirtied=280 written=66 -> Seq Scan on orders (cost=0.00..407703.43 rows=15164943 width=20) (actual time=0.018..7487.086 rows=15015000 loops=1) Buffers: shared hit=166016 read=90038 dirtied=280 written=66 Total runtime: 32589.770 ms (19 rows) COMMIT; COMMIT