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 ('MAIL', '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=988000.03..988000.03 rows=1 width=27) (actual time=27106.559..27106.560 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=1174044 read=187388 dirtied=5 written=1794 -> HashAggregate (cost=988000.01..988000.02 rows=1 width=27) (actual time=27106.501..27106.502 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=1174039 read=187388 dirtied=5 written=1794 -> Hash Join (cost=596085.37..982877.14 rows=292735 width=27) (actual time=11674.924..26679.005 rows=312636 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1174039 read=187388 dirtied=5 written=1794 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..377644.24 rows=292735 width=15) (actual time=0.097..14398.573 rows=312636 loops=1) Filter: ((l_shipmode = ANY ('{MAIL,TRUCK}'::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: 6883906 Buffers: shared hit=948508 read=157368 dirtied=5 written=1753 -> Hash (cost=406897.75..406897.75 rows=15134975 width=20) (actual time=11551.778..11551.778 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=225528 read=30020 written=41 -> Seq Scan on orders (cost=0.00..406897.75 rows=15134975 width=20) (actual time=0.022..5487.732 rows=15015000 loops=1) Buffers: shared hit=225528 read=30020 written=41 Planning time: 2.953 ms Execution time: 27129.235 ms (21 rows) COMMIT; COMMIT