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 ('REG AIR', 'MAIL') 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=989149.94..989149.95 rows=1 width=27) (actual time=25473.112..25473.113 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=654537 read=712675 dirtied=887 written=9268 -> HashAggregate (cost=989149.92..989149.93 rows=1 width=27) (actual time=25473.055..25473.056 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=654532 read=712675 dirtied=887 written=9268 -> Hash Join (cost=596675.51..984027.15 rows=292730 width=27) (actual time=11249.796..25169.506 rows=313311 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=654532 read=712675 dirtied=887 written=9268 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..378204.26 rows=292730 width=15) (actual time=0.395..13562.470 rows=313311 loops=1) Filter: ((l_shipmode = ANY ('{"REG AIR",MAIL}'::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: 6876059 Buffers: shared hit=501378 read=610025 dirtied=755 written=5629 -> Hash (cost=407300.59..407300.59 rows=15149959 width=20) (actual time=11130.897..11130.897 rows=15000000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 892791kB Buffers: shared hit=153151 read=102650 dirtied=132 written=3639 -> Seq Scan on orders (cost=0.00..407300.59 rows=15149959 width=20) (actual time=0.021..5805.364 rows=15000000 loops=1) Buffers: shared hit=153151 read=102650 dirtied=132 written=3639 Planning time: 3.350 ms Execution time: 25491.745 ms (21 rows) COMMIT; COMMIT