BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select o_orderpriority, count(*) as order_count from orders where o_orderdate >= date '1995-10-01' and o_orderdate < cast(date '1995-10-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=1293658.82..1293658.82 rows=1 width=16) (actual time=94071.671..94071.672 rows=5 loops=1) Sort Key: orders.o_orderpriority Sort Method: quicksort Memory: 25kB Buffers: shared hit=521228 read=996352 dirtied=594 written=10740 -> HashAggregate (cost=1293658.80..1293658.81 rows=1 width=16) (actual time=94071.504..94071.507 rows=5 loops=1) Buffers: shared hit=521223 read=996352 dirtied=594 written=10740 -> Hash Join (cost=1023717.93..1292886.61 rows=154438 width=16) (actual time=80446.158..93740.743 rows=525069 loops=1) Hash Cond: (orders.o_orderkey = lineitem.l_orderkey) Buffers: shared hit=521223 read=996352 dirtied=594 written=10740 -> Bitmap Heap Scan on orders (cost=12344.99..275983.60 rows=573174 width=20) (actual time=455.752..2585.187 rows=572593 loops=1) Recheck Cond: ((o_orderdate >= '1995-10-01'::date) AND (o_orderdate < '1996-01-01'::date)) Buffers: shared hit=228359 read=3092 -> Bitmap Index Scan on orders_o_orderdate_o_orderkey_idx (cost=0.00..12201.69 rows=573174 width=0) (actual time=338.499..338.499 rows=576665 loops=1) Index Cond: ((o_orderdate >= '1995-10-01'::date) AND (o_orderdate < '1996-01-01'::date)) Buffers: shared read=1616 -> Hash (cost=994414.93..994414.93 rows=1356641 width=4) (actual time=79988.077..79988.077 rows=13753444 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 483520kB Buffers: shared hit=292864 read=993260 dirtied=594 written=10740 -> HashAggregate (cost=980848.52..994414.93 rows=1356641 width=4) (actual time=64806.648..74149.476 rows=13753444 loops=1) Buffers: shared hit=292864 read=993260 dirtied=594 written=10740 -> Index Scan using lineitem_l_orderkey_idx_part1 on lineitem (cost=0.00..930511.27 rows=20134903 width=4) (actual time=0.200..31416.845 rows=37927958 loops=1) Buffers: shared hit=292864 read=993260 dirtied=594 written=10740 Total runtime: 94381.220 ms (23 rows) COMMIT; COMMIT