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 ('RAIL', 'TRUCK') 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=3053236.78..3053236.79 rows=1 width=27) (actual time=33203.942..33203.942 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=1035612 read=297567 dirtied=253 written=857 -> HashAggregate (cost=3053236.76..3053236.77 rows=1 width=27) (actual time=33203.892..33203.893 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=1035607 read=297567 dirtied=253 written=857 -> Hash Join (cost=597265.22..3048087.86 rows=294223 width=27) (actual time=9804.701..32913.138 rows=312559 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1035607 read=297567 dirtied=253 written=857 -> Seq Scan on lineitem (cost=0.00..2441628.17 rows=294223 width=15) (actual time=0.029..22787.659 rows=312559 loops=1) Filter: ((l_shipmode = ANY ('{RAIL,TRUCK}'::bpchar[])) AND (l_commitdate < l_receiptdate) AND (l_shipdate < l_commitdate) AND (l_receiptdate >= '1996-01-01'::date) AND (l_receiptdate < '1997-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 59732313 Buffers: shared hit=936456 read=140661 -> Hash (cost=407703.43..407703.43 rows=15164943 width=20) (actual time=9759.336..9759.336 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=99148 read=156906 dirtied=253 written=857 -> Seq Scan on orders (cost=0.00..407703.43 rows=15164943 width=20) (actual time=0.011..5321.474 rows=15015000 loops=1) Buffers: shared hit=99148 read=156906 dirtied=253 written=857 Planning time: 2.369 ms Execution time: 33209.898 ms (21 rows) COMMIT; COMMIT