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', 'TRUCK') 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=994841.67..994841.68 rows=1 width=27) (actual time=58283.088..58283.089 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=1139723 read=231719 written=35 -> HashAggregate (cost=994841.65..994841.66 rows=1 width=27) (actual time=58282.954..58282.955 rows=2 loops=1) Buffers: shared hit=1139718 read=231719 written=35 -> Hash Join (cost=600218.27..989716.53 rows=292864 width=27) (actual time=25354.567..57593.511 rows=311232 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1139718 read=231719 written=35 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.00..380346.26 rows=292864 width=15) (actual time=0.257..30704.020 rows=311232 loops=1) Filter: ((l_shipmode = ANY ('{FOB,TRUCK}'::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: 6885383 Buffers: shared hit=919594 read=194520 written=35 -> Hash (cost=409719.23..409719.23 rows=15239923 width=20) (actual time=25344.067..25344.067 rows=15015000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 762481kB Buffers: shared hit=220121 read=37199 -> Seq Scan on orders (cost=0.00..409719.23 rows=15239923 width=20) (actual time=0.018..16211.219 rows=15015000 loops=1) Buffers: shared hit=220121 read=37199 Total runtime: 58470.562 ms (19 rows) COMMIT; COMMIT