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 ('AIR', 'RAIL') 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=991534.44..991534.44 rows=1 width=27) (actual time=51177.697..51177.697 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=654512 read=715274 dirtied=310 written=53764 -> HashAggregate (cost=991534.42..991534.43 rows=1 width=27) (actual time=51177.584..51177.585 rows=2 loops=1) Buffers: shared hit=654507 read=715274 dirtied=310 written=53764 -> Hash Join (cost=597855.36..986389.28 rows=294008 width=27) (actual time=18721.040..50525.764 rows=312810 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=654507 read=715274 dirtied=310 written=53764 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.00..379346.17 rows=294008 width=15) (actual time=0.285..30535.798 rows=312810 loops=1) Filter: ((l_shipmode = ANY ('{AIR,RAIL}'::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: 6883716 Buffers: shared hit=399788 read=713683 dirtied=57 written=53764 -> Hash (cost=408106.27..408106.27 rows=15179927 width=20) (actual time=18709.530..18709.530 rows=15015000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 762481kB Buffers: shared hit=254716 read=1591 dirtied=253 -> Seq Scan on orders (cost=0.00..408106.27 rows=15179927 width=20) (actual time=0.019..9328.882 rows=15015000 loops=1) Buffers: shared hit=254716 read=1591 dirtied=253 Total runtime: 51308.232 ms (19 rows) COMMIT; COMMIT