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', 'FOB') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1997-01-01' and l_receiptdate < date '1997-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=981940.62..981940.62 rows=1 width=27) (actual time=22107.458..22107.458 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=938231 read=424390 dirtied=311 written=49 -> HashAggregate (cost=981940.60..981940.61 rows=1 width=27) (actual time=22107.403..22107.404 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=938226 read=424390 dirtied=311 written=49 -> Hash Join (cost=592539.85..976858.09 rows=290429 width=27) (actual time=11302.759..21824.029 rows=311544 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=938226 read=424390 dirtied=311 written=49 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..375242.77 rows=290429 width=15) (actual time=0.279..10197.035 rows=311544 loops=1) Filter: ((l_shipmode = ANY ('{RAIL,FOB}'::bpchar[])) AND (l_receiptdate >= '1997-01-01'::date) AND (l_receiptdate < '1998-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6885707 Buffers: shared hit=744682 read=363903 dirtied=58 written=49 -> Hash (cost=404477.52..404477.52 rows=15044952 width=20) (actual time=11172.697..11172.697 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=193541 read=60487 dirtied=253 -> Seq Scan on orders (cost=0.00..404477.52 rows=15044952 width=20) (actual time=0.019..5199.564 rows=15015000 loops=1) Buffers: shared hit=193541 read=60487 dirtied=253 Planning time: 2.709 ms Execution time: 22113.315 ms (21 rows) COMMIT; COMMIT