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', 'REG 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=987587.16..987587.17 rows=1 width=27) (actual time=23928.640..23928.641 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=1053342 read=314875 dirtied=58 written=593 -> HashAggregate (cost=987587.14..987587.15 rows=1 width=27) (actual time=23928.577..23928.578 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=1053337 read=314875 dirtied=58 written=593 -> Hash Join (cost=595495.23..982425.16 rows=294970 width=27) (actual time=11691.660..23647.887 rows=312350 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1053337 read=314875 dirtied=58 written=593 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..377712.55 rows=294970 width=15) (actual time=0.314..11530.460 rows=312350 loops=1) Filter: ((l_shipmode = ANY ('{RAIL,"REG 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: 6884409 Buffers: shared hit=821348 read=291566 dirtied=58 written=564 -> Hash (cost=406494.91..406494.91 rows=15119991 width=20) (actual time=11566.548..11566.548 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=231986 read=23309 written=29 -> Seq Scan on orders (cost=0.00..406494.91 rows=15119991 width=20) (actual time=0.017..5265.330 rows=15015000 loops=1) Buffers: shared hit=231986 read=23309 written=29 Planning time: 2.985 ms Execution time: 23950.529 ms (21 rows) COMMIT; COMMIT