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 ('FOB', '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=991902.80..991902.80 rows=1 width=27) (actual time=26587.894..26587.895 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=1058477 read=308008 dirtied=13 written=376 -> HashAggregate (cost=991902.78..991902.79 rows=1 width=27) (actual time=26587.816..26587.818 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=1058472 read=308008 dirtied=13 written=376 -> Hash Join (cost=598445.93..986766.69 rows=293491 width=27) (actual time=12552.888..26243.975 rows=312866 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1058472 read=308008 dirtied=13 written=376 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..379149.59 rows=293491 width=15) (actual time=0.272..13178.704 rows=312866 loops=1) Filter: ((l_shipmode = ANY ('{FOB,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: 6883804 Buffers: shared hit=903992 read=205925 written=258 -> Hash (cost=408509.11..408509.11 rows=15194911 width=20) (actual time=12309.290..12309.290 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=154477 read=102083 dirtied=13 written=118 -> Seq Scan on orders (cost=0.00..408509.11 rows=15194911 width=20) (actual time=0.027..6169.742 rows=15015000 loops=1) Buffers: shared hit=154477 read=102083 dirtied=13 written=118 Planning time: 4.361 ms Execution time: 26611.271 ms (21 rows) COMMIT; COMMIT