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', 'AIR') 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=985775.58..985775.59 rows=1 width=27) (actual time=36373.820..36373.821 rows=2 loops=1) Sort Key: lineitem.l_shipmode Sort Method: quicksort Memory: 25kB Buffers: shared hit=663369 read=700348 dirtied=1068 written=49432 -> HashAggregate (cost=985775.56..985775.57 rows=1 width=27) (actual time=36373.731..36373.732 rows=2 loops=1) Buffers: shared hit=663364 read=700348 dirtied=1068 written=49432 -> Hash Join (cost=594309.84..980681.79 rows=291073 width=27) (actual time=14968.180..35794.149 rows=311550 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=663364 read=700348 dirtied=1068 written=49432 -> Index Scan using lineitem_l_orderkey_idx_part2 on lineitem (cost=0.00..377275.92 rows=291073 width=15) (actual time=0.201..19434.438 rows=311550 loops=1) Filter: ((l_shipmode = ANY ('{SHIP,AIR}'::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: 6885315 Buffers: shared hit=408574 read=700348 dirtied=1068 written=49432 -> Hash (cost=405686.04..405686.04 rows=15089904 width=20) (actual time=14958.089..14958.089 rows=15015000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 762481kB Buffers: shared hit=254787 -> Seq Scan on orders (cost=0.00..405686.04 rows=15089904 width=20) (actual time=0.018..6749.206 rows=15015000 loops=1) Buffers: shared hit=254787 Total runtime: 36501.863 ms (19 rows) COMMIT; COMMIT