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 ('AIR', 'TRUCK') 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=989725.47..989725.48 rows=1 width=27) (actual time=37736.281..37736.281 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=546504 read=826188 dirtied=1140 written=34894 -> HashAggregate (cost=989725.45..989725.46 rows=1 width=27) (actual time=37736.153..37736.154 rows=2 loops=1) Buffers: shared hit=546499 read=826188 dirtied=1140 written=34894 -> Hash Join (cost=596675.08..984590.39 rows=293432 width=27) (actual time=14566.547..37130.957 rows=312871 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=546499 read=826188 dirtied=1140 written=34894 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.00..378745.57 rows=293432 width=15) (actual time=0.171..21512.758 rows=312871 loops=1) Filter: ((l_shipmode = ANY ('{AIR,TRUCK}'::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: 6883691 Buffers: shared hit=290760 read=826123 dirtied=1140 written=34894 -> Hash (cost=407300.59..407300.59 rows=15149959 width=20) (actual time=14557.208..14557.208 rows=15015000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 762481kB Buffers: shared hit=255736 read=65 -> Seq Scan on orders (cost=0.00..407300.59 rows=15149959 width=20) (actual time=0.017..7173.870 rows=15015000 loops=1) Buffers: shared hit=255736 read=65 Total runtime: 37815.520 ms (19 rows) COMMIT; COMMIT