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', 'FOB') 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=985053.74..985053.74 rows=1 width=27) (actual time=24902.897..24902.898 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=270512 read=1096631 dirtied=452 written=23653 -> HashAggregate (cost=985053.72..985053.73 rows=1 width=27) (actual time=24902.840..24902.841 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=270507 read=1096631 dirtied=452 written=23653 -> Hash Join (cost=594310.27..979951.12 rows=291577 width=27) (actual time=10369.088..24614.544 rows=311470 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=270507 read=1096631 dirtied=452 written=23653 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..376529.50 rows=291577 width=15) (actual time=0.151..13852.776 rows=311470 loops=1) Filter: ((l_shipmode = ANY ('{SHIP,FOB}'::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: 6878144 Buffers: shared hit=75429 read=1036919 dirtied=430 written=19737 -> Hash (cost=405686.04..405686.04 rows=15089904 width=20) (actual time=10026.263..10026.263 rows=15000000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 892791kB Buffers: shared hit=195075 read=59712 dirtied=22 written=3916 -> Seq Scan on orders (cost=0.00..405686.04 rows=15089904 width=20) (actual time=0.013..4965.496 rows=15000000 loops=1) Buffers: shared hit=195075 read=59712 dirtied=22 written=3916 Planning time: 3.084 ms Execution time: 24925.877 ms (21 rows) COMMIT; COMMIT