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', 'REG 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=988008.61..988008.61 rows=1 width=27) (actual time=27971.531..27971.532 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=1124173 read=244435 dirtied=113 written=1654 -> HashAggregate (cost=988008.59..988008.60 rows=1 width=27) (actual time=27971.461..27971.461 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=1124168 read=244435 dirtied=113 written=1654 -> Hash Join (cost=596085.37..982882.64 rows=292911 width=27) (actual time=10991.205..27496.323 rows=312781 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1124168 read=244435 dirtied=113 written=1654 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..377644.24 rows=292911 width=15) (actual time=0.468..15934.830 rows=312781 loops=1) Filter: ((l_shipmode = ANY ('{RAIL,"REG 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: 6883761 Buffers: shared hit=934575 read=178477 dirtied=113 written=1612 -> Hash (cost=406897.75..406897.75 rows=15134975 width=20) (actual time=10930.900..10930.900 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=189590 read=65958 written=42 -> Seq Scan on orders (cost=0.00..406897.75 rows=15134975 width=20) (actual time=0.029..5878.123 rows=15015000 loops=1) Buffers: shared hit=189590 read=65958 written=42 Planning time: 4.266 ms Execution time: 27976.773 ms (21 rows) COMMIT; COMMIT