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 '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=3038129.27..3038129.28 rows=1 width=27) (actual time=34833.291..34833.292 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=774391 read=552199 dirtied=82 written=2729 -> HashAggregate (cost=3038129.25..3038129.26 rows=1 width=27) (actual time=34833.239..34833.240 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=774386 read=552199 dirtied=82 written=2729 -> Hash Join (cost=594309.84..3033011.99 rows=292415 width=27) (actual time=9766.073..34490.948 rows=311761 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=774386 read=552199 dirtied=82 written=2729 -> Seq Scan on lineitem (cost=0.00..2429564.18 rows=292415 width=15) (actual time=0.090..24392.483 rows=311761 loops=1) Filter: ((l_shipmode = ANY ('{AIR,RAIL}'::bpchar[])) AND (l_commitdate < l_receiptdate) AND (l_shipdate < l_commitdate) AND (l_receiptdate >= '1995-01-01'::date) AND (l_receiptdate < '1996-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 59673926 Buffers: shared hit=594222 read=477573 dirtied=1 -> Hash (cost=405686.04..405686.04 rows=15089904 width=20) (actual time=9683.384..9683.384 rows=15000000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 892791kB Buffers: shared hit=180161 read=74626 dirtied=81 written=2729 -> Seq Scan on orders (cost=0.00..405686.04 rows=15089904 width=20) (actual time=0.011..4821.292 rows=15000000 loops=1) Buffers: shared hit=180161 read=74626 dirtied=81 written=2729 Planning time: 2.337 ms Execution time: 34848.348 ms (21 rows) COMMIT; COMMIT