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 ('MAIL', 'RAIL') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1994-01-01' and l_receiptdate < date '1994-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=990711.52..990711.53 rows=1 width=27) (actual time=41661.144..41661.144 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=673278 read=692482 written=275 -> HashAggregate (cost=990711.50..990711.51 rows=1 width=27) (actual time=41661.016..41661.017 rows=2 loops=1) Buffers: shared hit=673273 read=692482 written=275 -> Hash Join (cost=597265.22..985570.65 rows=293763 width=27) (actual time=17402.974..41038.802 rows=311283 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=673273 read=692482 written=275 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.00..379125.34 rows=293763 width=15) (actual time=0.143..22185.260 rows=311283 loops=1) Filter: ((l_shipmode = ANY ('{MAIL,RAIL}'::bpchar[])) AND (l_receiptdate >= '1994-01-01'::date) AND (l_receiptdate < '1995-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6885299 Buffers: shared hit=435750 read=673948 written=269 -> Hash (cost=407703.43..407703.43 rows=15164943 width=20) (actual time=17390.048..17390.048 rows=15015000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 762481kB Buffers: shared hit=237520 read=18534 written=6 -> Seq Scan on orders (cost=0.00..407703.43 rows=15164943 width=20) (actual time=0.032..7527.472 rows=15015000 loops=1) Buffers: shared hit=237520 read=18534 written=6 Total runtime: 41803.828 ms (19 rows) COMMIT; COMMIT