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', 'AIR') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1995-01-01' and l_receiptdate < date '1995-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=991576.14..991576.14 rows=1 width=27) (actual time=22828.027..22828.027 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=793866 read=576442 dirtied=1595 written=5474 -> HashAggregate (cost=991576.12..991576.13 rows=1 width=27) (actual time=22827.963..22827.965 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=793861 read=576442 dirtied=1595 written=5474 -> Hash Join (cost=598445.93..986497.36 rows=290215 width=27) (actual time=11369.968..22559.228 rows=312537 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=793861 read=576442 dirtied=1595 written=5474 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..378982.64 rows=290215 width=15) (actual time=0.195..10840.081 rows=312537 loops=1) Filter: ((l_shipmode = ANY ('{"REG AIR",AIR}'::bpchar[])) AND (l_receiptdate >= '1995-01-01'::date) AND (l_receiptdate < '1996-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6876934 Buffers: shared hit=697109 read=416631 dirtied=1087 written=4896 -> Hash (cost=408509.11..408509.11 rows=15194911 width=20) (actual time=11311.417..11311.417 rows=15000000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 892791kB Buffers: shared hit=96749 read=159811 dirtied=508 written=578 -> Seq Scan on orders (cost=0.00..408509.11 rows=15194911 width=20) (actual time=0.014..5428.130 rows=15000000 loops=1) Buffers: shared hit=96749 read=159811 dirtied=508 written=578 Planning time: 2.810 ms Execution time: 22834.057 ms (21 rows) COMMIT; COMMIT