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 ('RAIL', 'TRUCK') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1994-01-01' and l_receiptdate < date '1994-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=3022883.53..3022883.54 rows=1 width=27) (actual time=35817.031..35817.031 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=718513 read=601490 -> HashAggregate (cost=3022883.51..3022883.52 rows=1 width=27) (actual time=35816.974..35816.974 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=718508 read=601490 -> Hash Join (cost=591359.14..3017849.18 rows=287676 width=27) (actual time=10467.821..35507.162 rows=311650 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=718508 read=601490 -> Seq Scan on lineitem (cost=0.00..2417500.17 rows=287676 width=15) (actual time=0.059..24633.497 rows=311650 loops=1) Filter: ((l_shipmode = ANY ('{RAIL,TRUCK}'::bpchar[])) AND (l_commitdate < l_receiptdate) AND (l_shipdate < l_commitdate) AND (l_receiptdate >= '1994-01-01'::date) AND (l_receiptdate < '1995-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 59734019 Buffers: shared hit=594203 read=472270 -> Hash (cost=403671.84..403671.84 rows=15014984 width=20) (actual time=10399.086..10399.086 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=124302 read=129220 -> Seq Scan on orders (cost=0.00..403671.84 rows=15014984 width=20) (actual time=0.007..4849.495 rows=15015000 loops=1) Buffers: shared hit=124302 read=129220 Planning time: 1.991 ms Execution time: 35821.340 ms (21 rows) COMMIT; COMMIT