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 ('TRUCK', 'RAIL') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1993-01-01' and l_receiptdate < date '1993-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Sort (cost=980337.21..980337.21 rows=1 width=27) (actual time=24909.205..24909.206 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=363348 read=991142 -> HashAggregate (cost=980337.19..980337.20 rows=1 width=27) (actual time=24909.103..24909.104 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=363343 read=991142 -> Hash Join (cost=591359.57..975262.96 rows=289956 width=27) (actual time=9538.854..24623.990 rows=312773 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=363343 read=991142 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..374842.69 rows=289956 width=15) (actual time=0.160..14681.709 rows=312773 loops=1) Filter: ((l_shipmode = ANY ('{TRUCK,RAIL}'::bpchar[])) AND (l_receiptdate >= '1993-01-01'::date) AND (l_receiptdate < '1994-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6884631 Buffers: shared hit=109818 read=991142 -> Hash (cost=403671.84..403671.84 rows=15014984 width=20) (actual time=9458.411..9458.411 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=253522 -> Seq Scan on orders (cost=0.00..403671.84 rows=15014984 width=20) (actual time=0.015..4666.815 rows=15015000 loops=1) Buffers: shared hit=253522 Planning time: 4.312 ms Execution time: 24917.786 ms (21 rows) COMMIT; COMMIT