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 '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=992312.98..992312.98 rows=1 width=27) (actual time=34588.417..34588.417 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=610786 read=763058 dirtied=624 written=5263 -> HashAggregate (cost=992312.96..992312.97 rows=1 width=27) (actual time=34588.326..34588.328 rows=2 loops=1) Buffers: shared hit=610781 read=763058 dirtied=624 written=5263 -> Hash Join (cost=598445.50..987164.47 rows=294199 width=27) (actual time=14617.453..34057.203 rows=311756 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=610781 read=763058 dirtied=624 written=5263 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.00..379525.26 rows=294199 width=15) (actual time=0.196..18028.488 rows=311756 loops=1) Filter: ((l_shipmode = ANY ('{TRUCK,RAIL}'::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: 6884914 Buffers: shared hit=362009 read=755267 dirtied=112 written=3715 -> Hash (cost=408509.11..408509.11 rows=15194911 width=20) (actual time=14594.392..14594.392 rows=15015000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 762481kB Buffers: shared hit=248769 read=7791 dirtied=512 written=1548 -> Seq Scan on orders (cost=0.00..408509.11 rows=15194911 width=20) (actual time=0.026..6452.605 rows=15015000 loops=1) Buffers: shared hit=248769 read=7791 dirtied=512 written=1548 Total runtime: 34738.607 ms (19 rows) COMMIT; COMMIT