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', 'AIR') 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=985211.90..985211.90 rows=1 width=27) (actual time=23402.803..23402.804 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=895279 read=468437 written=2 -> HashAggregate (cost=985211.88..985211.89 rows=1 width=27) (actual time=23402.739..23402.739 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=895274 read=468437 written=2 -> Hash Join (cost=594310.27..980118.54 rows=291048 width=27) (actual time=10314.781..23107.505 rows=312047 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=895274 read=468437 written=2 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..376713.44 rows=291048 width=15) (actual time=0.295..12491.383 rows=312047 loops=1) Filter: ((l_shipmode = ANY ('{RAIL,AIR}'::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: 6884818 Buffers: shared hit=642843 read=466078 -> Hash (cost=405686.04..405686.04 rows=15089904 width=20) (actual time=10217.014..10217.014 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=252428 read=2359 written=2 -> Seq Scan on orders (cost=0.00..405686.04 rows=15089904 width=20) (actual time=0.018..5190.360 rows=15015000 loops=1) Buffers: shared hit=252428 read=2359 written=2 Planning time: 3.287 ms Execution time: 23424.339 ms (21 rows) COMMIT; COMMIT