BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select o_orderpriority, count(*) as order_count from orders where o_orderdate >= date '1995-04-01' and o_orderdate < cast(date '1995-04-01' + interval '3 month' as date) and exists ( select * from lineitem where l_orderkey = o_orderkey and l_commitdate < l_receiptdate ) group by o_orderpriority order by o_orderpriority; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Sort (cost=1150571.19..1150571.19 rows=1 width=16) (actual time=10972.212..10972.212 rows=5 loops=1) Sort Key: orders.o_orderpriority Sort Method: quicksort Memory: 25kB Buffers: shared hit=2845378 read=177628 -> HashAggregate (cost=1150571.17..1150571.18 rows=1 width=16) (actual time=10972.144..10972.147 rows=5 loops=1) Group Key: orders.o_orderpriority Buffers: shared hit=2845373 read=177628 -> Nested Loop Semi Join (cost=12187.47..1149787.08 rows=156817 width=16) (actual time=323.620..10619.060 rows=520666 loops=1) Buffers: shared hit=2845373 read=177628 -> Bitmap Heap Scan on orders (cost=12186.90..275099.80 rows=575460 width=20) (actual time=323.534..2384.079 rows=567722 loops=1) Recheck Cond: ((o_orderdate >= '1995-04-01'::date) AND (o_orderdate < '1995-07-01'::date)) Heap Blocks: exact=228345 Buffers: shared hit=200885 read=29013 -> Bitmap Index Scan on orders_o_orderdate_o_orderkey_idx (cost=0.00..12043.03 rows=575460 width=0) (actual time=240.967..240.967 rows=569410 loops=1) Index Cond: ((o_orderdate >= '1995-04-01'::date) AND (o_orderdate < '1995-07-01'::date)) Buffers: shared hit=1 read=1552 -> Index Scan using lineitem_l_orderkey_idx_part1 on lineitem (cost=0.56..4.56 rows=5 width=4) (actual time=0.013..0.013 rows=1 loops=567722) Index Cond: (l_orderkey = orders.o_orderkey) Buffers: shared hit=2644488 read=148615 Planning time: 2.959 ms Execution time: 10974.104 ms (21 rows) COMMIT; COMMIT