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 ('TRUCK', 'SHIP') 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=991439.04..991439.04 rows=1 width=27) (actual time=48386.719..48386.720 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=1178473 read=191313 written=63 -> HashAggregate (cost=991439.02..991439.03 rows=1 width=27) (actual time=48386.591..48386.592 rows=2 loops=1) Buffers: shared hit=1178468 read=191313 written=63 -> Hash Join (cost=597855.36..986328.12 rows=292051 width=27) (actual time=20445.958..47772.896 rows=313231 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1178468 read=191313 written=63 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.00..379346.17 rows=292051 width=15) (actual time=0.257..25693.703 rows=313231 loops=1) Filter: ((l_shipmode = ANY ('{TRUCK,SHIP}'::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: 6883295 Buffers: shared hit=924784 read=188687 written=63 -> Hash (cost=408106.27..408106.27 rows=15179927 width=20) (actual time=20437.080..20437.080 rows=15015000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 762481kB Buffers: shared hit=253681 read=2626 -> Seq Scan on orders (cost=0.00..408106.27 rows=15179927 width=20) (actual time=0.023..10638.681 rows=15015000 loops=1) Buffers: shared hit=253681 read=2626 Total runtime: 48607.352 ms (19 rows) COMMIT; COMMIT