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 ('REG AIR', 'AIR') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1996-01-01' and l_receiptdate < date '1996-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=983239.72..983239.72 rows=1 width=27) (actual time=45174.964..45174.964 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=710030 read=653476 dirtied=82 written=19440 -> HashAggregate (cost=983239.70..983239.71 rows=1 width=27) (actual time=45174.831..45174.832 rows=2 loops=1) Buffers: shared hit=710025 read=653476 dirtied=82 written=19440 -> Hash Join (cost=592539.42..978124.27 rows=292310 width=27) (actual time=16427.355..44469.877 rows=313921 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=710025 read=653476 dirtied=82 written=19440 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.00..376450.17 rows=292310 width=15) (actual time=0.415..26350.714 rows=313921 loops=1) Filter: ((l_shipmode = ANY ('{"REG AIR",AIR}'::bpchar[])) AND (l_receiptdate >= '1996-01-01'::date) AND (l_receiptdate < '1997-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6883330 Buffers: shared hit=456928 read=652542 dirtied=82 written=19440 -> Hash (cost=404477.52..404477.52 rows=15044952 width=20) (actual time=16163.984..16163.984 rows=15015000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 762481kB Buffers: shared hit=253094 read=934 -> Seq Scan on orders (cost=0.00..404477.52 rows=15044952 width=20) (actual time=0.019..7135.418 rows=15015000 loops=1) Buffers: shared hit=253094 read=934 Total runtime: 45397.237 ms (19 rows) COMMIT; COMMIT