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 ('SHIP', 'TRUCK') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date '1994-01-01' and l_receiptdate < date '1994-01-01' + interval '1 year' group by l_shipmode order by l_shipmode; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Sort (cost=982174.73..982174.73 rows=1 width=27) (actual time=26812.235..26812.236 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=873264 read=485651 dirtied=1032 written=7977 -> HashAggregate (cost=982174.71..982174.72 rows=1 width=27) (actual time=26812.170..26812.171 rows=2 loops=1) Group Key: lineitem.l_shipmode Buffers: shared hit=873259 read=485651 dirtied=1032 written=7977 -> Hash Join (cost=592539.85..977133.04 rows=288095 width=27) (actual time=11341.762..26457.741 rows=311442 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=873259 read=485651 dirtied=1032 written=7977 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.43..375590.66 rows=288095 width=15) (actual time=0.127..14589.922 rows=311442 loops=1) Filter: ((l_shipmode = ANY ('{SHIP,TRUCK}'::bpchar[])) AND (l_receiptdate >= '1994-01-01'::date) AND (l_receiptdate < '1995-01-01 00:00:00'::timestamp without time zone)) Rows Removed by Filter: 6885809 Buffers: shared hit=670915 read=433964 dirtied=1032 written=7977 -> Hash (cost=404477.52..404477.52 rows=15044952 width=20) (actual time=11213.068..11213.068 rows=15015000 loops=1) Buckets: 16777216 Batches: 1 Memory Usage: 893553kB Buffers: shared hit=202341 read=51687 -> Seq Scan on orders (cost=0.00..404477.52 rows=15044952 width=20) (actual time=0.022..5474.740 rows=15015000 loops=1) Buffers: shared hit=202341 read=51687 Planning time: 3.018 ms Execution time: 26848.375 ms (21 rows) COMMIT; COMMIT