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 '1995-01-01' and l_receiptdate < date '1995-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Sort (cost=992122.35..992122.35 rows=1 width=27) (actual time=26146.727..26146.727 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=619174 read=747311 written=586 -> HashAggregate (cost=992122.33..992122.34 rows=1 width=27) (actual time=26146.666..26146.667 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=619169 read=747311 written=586 -> Hash Join (cost=598445.93..986973.81 rows=294201 width=27) (actual time=11487.620..25843.780 rows=311756 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=619169 read=747311 written=586 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..379334.53 rows=294201 width=15) (actual time=0.085..13891.069 rows=311756 loops=1) Filter: ((l_shipmode = ANY ('{RAIL,TRUCK}'::bpchar[])) AND (l_receiptdate >= '1995-01-01'::date) AND (l_receiptdate < '1996-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6884914 Buffers: shared hit=496181 read=613736 written=362 -> Hash (cost=408509.11..408509.11 rows=15194911 width=20) (actual time=11019.549..11019.549 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=122985 read=133575 written=224 -> Seq Scan on orders (cost=0.00..408509.11 rows=15194911 width=20) (actual time=0.024..5847.823 rows=15015000 loops=1) Buffers: shared hit=122985 read=133575 written=224 Planning time: 3.415 ms Execution time: 26166.716 ms (21 rows) COMMIT; COMMIT