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 ('SHIP', '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=984277.06..984277.07 rows=1 width=27) (actual time=88766.777..88766.777 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=900270 read=466764 written=37 -> HashAggregate (cost=984277.04..984277.05 rows=1 width=27) (actual time=88766.644..88766.646 rows=2 loops=1) Buffers: shared hit=900265 read=466764 written=37 -> Hash Join (cost=593719.70..979134.75 rows=293845 width=27) (actual time=24511.820..87946.152 rows=313295 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=900265 read=466764 written=37 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.00..376232.40 rows=293845 width=15) (actual time=0.287..61705.132 rows=313295 loops=1) Filter: ((l_shipmode = ANY ('{SHIP,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: 6883907 Buffers: shared hit=650097 read=462395 written=36 -> Hash (cost=405283.20..405283.20 rows=15074920 width=20) (actual time=24489.037..24489.037 rows=15015000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 762481kB Buffers: shared hit=250165 read=4369 written=1 -> Seq Scan on orders (cost=0.00..405283.20 rows=15074920 width=20) (actual time=0.017..14140.463 rows=15015000 loops=1) Buffers: shared hit=250165 read=4369 written=1 Total runtime: 88955.280 ms (19 rows) COMMIT; COMMIT