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 '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=991138.84..991138.84 rows=1 width=27) (actual time=43148.674..43148.675 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=457166 read=912620 dirtied=1646 written=135 -> HashAggregate (cost=991138.82..991138.83 rows=1 width=27) (actual time=43148.559..43148.560 rows=2 loops=1) Buffers: shared hit=457161 read=912620 dirtied=1646 written=135 -> Hash Join (cost=597855.36..985969.21 rows=295406 width=27) (actual time=16731.579..42512.337 rows=313524 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=457161 read=912620 dirtied=1646 written=135 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.00..378882.42 rows=295406 width=15) (actual time=0.096..24574.304 rows=313524 loops=1) Filter: ((l_shipmode = ANY ('{FOB,"REG AIR"}'::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: 6883002 Buffers: shared hit=203067 read=910404 dirtied=1398 written=135 -> Hash (cost=408106.27..408106.27 rows=15179927 width=20) (actual time=16719.711..16719.711 rows=15015000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 762481kB Buffers: shared hit=254091 read=2216 dirtied=248 -> Seq Scan on orders (cost=0.00..408106.27 rows=15179927 width=20) (actual time=0.023..9045.593 rows=15015000 loops=1) Buffers: shared hit=254091 read=2216 dirtied=248 Total runtime: 43285.681 ms (19 rows) COMMIT; COMMIT