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 ('SHIP', '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=983263.64..983263.64 rows=1 width=27) (actual time=25366.166..25366.167 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=629589 read=733374 dirtied=843 written=35 -> HashAggregate (cost=983263.61..983263.62 rows=1 width=27) (actual time=25366.103..25366.103 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=629584 read=733374 dirtied=843 written=35 -> Hash Join (cost=593129.99..978176.08 rows=290716 width=27) (actual time=11602.207..25070.981 rows=312546 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=629584 read=733374 dirtied=843 written=35 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..375961.65 rows=290716 width=15) (actual time=0.296..13149.804 rows=312546 loops=1) Filter: ((l_shipmode = ANY ('{SHIP,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: 6884637 Buffers: shared hit=513671 read=595003 dirtied=361 written=29 -> Hash (cost=404880.36..404880.36 rows=15059936 width=20) (actual time=11482.781..11482.781 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=115910 read=138371 dirtied=482 written=6 -> Seq Scan on orders (cost=0.00..404880.36 rows=15059936 width=20) (actual time=0.020..5913.077 rows=15015000 loops=1) Buffers: shared hit=115910 read=138371 dirtied=482 written=6 Planning time: 3.153 ms Execution time: 25384.812 ms (21 rows) COMMIT; COMMIT