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 ('AIR', 'SHIP') 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=993918.23..993918.24 rows=1 width=27) (actual time=44490.672..44490.672 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=460631 read=913615 dirtied=1191 written=41654 -> HashAggregate (cost=993918.21..993918.22 rows=1 width=27) (actual time=44490.576..44490.577 rows=2 loops=1) Buffers: shared hit=460626 read=913615 dirtied=1191 written=41654 -> Hash Join (cost=599035.64..988781.77 rows=293511 width=27) (actual time=19438.567..43893.792 rows=312060 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=460626 read=913615 dirtied=1191 written=41654 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.00..380573.91 rows=293511 width=15) (actual time=0.168..22944.706 rows=312060 loops=1) Filter: ((l_shipmode = ANY ('{AIR,SHIP}'::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: 6884629 Buffers: shared hit=305673 read=811752 dirtied=938 written=41592 -> Hash (cost=408911.95..408911.95 rows=15209895 width=20) (actual time=19426.732..19426.732 rows=15015000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 762481kB Buffers: shared hit=154950 read=101863 dirtied=253 written=62 -> Seq Scan on orders (cost=0.00..408911.95 rows=15209895 width=20) (actual time=0.013..7931.544 rows=15015000 loops=1) Buffers: shared hit=154950 read=101863 dirtied=253 written=62 Total runtime: 44707.512 ms (19 rows) COMMIT; COMMIT