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', 'REG AIR') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1993-01-01' and l_receiptdate < date '1993-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=990911.97..990911.98 rows=1 width=27) (actual time=30012.171..30012.172 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=1060131 read=306101 written=3010 -> HashAggregate (cost=990911.95..990911.96 rows=1 width=27) (actual time=30012.105..30012.107 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=1060126 read=306101 written=3010 -> Hash Join (cost=597855.79..985784.81 rows=292980 width=27) (actual time=16046.074..29651.548 rows=312424 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1060126 read=306101 written=3010 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..378773.82 rows=292980 width=15) (actual time=0.250..12995.036 rows=312424 loops=1) Filter: ((l_shipmode = ANY ('{FOB,"REG AIR"}'::bpchar[])) AND (l_receiptdate >= '1993-01-01'::date) AND (l_receiptdate < '1994-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6876972 Buffers: shared hit=850282 read=259635 written=335 -> Hash (cost=408106.27..408106.27 rows=15179927 width=20) (actual time=11071.682..11071.682 rows=15000000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 892791kB Buffers: shared hit=209841 read=46466 written=2675 -> Seq Scan on orders (cost=0.00..408106.27 rows=15179927 width=20) (actual time=0.035..5597.518 rows=15000000 loops=1) Buffers: shared hit=209841 read=46466 written=2675 Planning time: 3.329 ms Execution time: 30045.358 ms (21 rows) COMMIT; COMMIT