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', 'TRUCK') 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=3035167.79..3035167.79 rows=1 width=27) (actual time=34664.416..34664.416 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=681546 read=643733 dirtied=253 written=1128 -> HashAggregate (cost=3035167.77..3035167.78 rows=1 width=27) (actual time=34664.365..34664.365 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=681541 read=643733 dirtied=253 written=1128 -> Hash Join (cost=593719.70..3030040.83 rows=292968 width=27) (actual time=10305.531..34340.330 rows=312460 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=681541 read=643733 dirtied=253 written=1128 -> Seq Scan on lineitem (cost=0.00..2427165.88 rows=292968 width=15) (actual time=0.054..23668.796 rows=312460 loops=1) Filter: ((l_shipmode = ANY ('{FOB,TRUCK}'::bpchar[])) AND (l_commitdate < l_receiptdate) AND (l_shipdate < l_commitdate) AND (l_receiptdate >= '1996-01-01'::date) AND (l_receiptdate < '1997-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 59733761 Buffers: shared hit=484889 read=585848 -> Hash (cost=405283.20..405283.20 rows=15074920 width=20) (actual time=10227.890..10227.890 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=196649 read=57885 dirtied=253 written=1128 -> Seq Scan on orders (cost=0.00..405283.20 rows=15074920 width=20) (actual time=0.013..4554.538 rows=15015000 loops=1) Buffers: shared hit=196649 read=57885 dirtied=253 written=1128 Planning time: 2.137 ms Execution time: 34677.909 ms (21 rows) COMMIT; COMMIT