BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select o_orderpriority, count(*) as order_count from orders where o_orderdate >= date '1997-07-01' and o_orderdate < cast(date '1997-07-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=1295644.98..1295644.99 rows=1 width=16) (actual time=146518.163..146518.164 rows=5 loops=1) Sort Key: orders.o_orderpriority Sort Method: quicksort Memory: 25kB Buffers: shared hit=922004 read=606391 dirtied=886 written=6783 -> HashAggregate (cost=1295644.96..1295644.97 rows=1 width=16) (actual time=146517.981..146517.983 rows=5 loops=1) Buffers: shared hit=921999 read=606391 dirtied=886 written=6783 -> Hash Join (cost=1025278.91..1294862.53 rows=156487 width=16) (actual time=129024.340..146095.622 rows=526401 loops=1) Hash Cond: (orders.o_orderkey = lineitem.l_orderkey) Buffers: shared hit=921999 read=606391 dirtied=886 written=6783 -> Bitmap Heap Scan on orders (cost=12563.52..276553.47 rows=579663 width=20) (actual time=757.925..7507.060 rows=574491 loops=1) Recheck Cond: ((o_orderdate >= '1997-07-01'::date) AND (o_orderdate < '1997-10-01'::date)) Buffers: shared hit=229914 read=1804 -> Bitmap Index Scan on orders_o_orderdate_o_orderkey_idx (cost=0.00..12418.61 rows=579663 width=0) (actual time=630.758..630.758 rows=578522 loops=1) Index Cond: ((o_orderdate >= '1997-07-01'::date) AND (o_orderdate < '1997-10-01'::date)) Buffers: shared read=1650 -> Hash (cost=995707.80..995707.80 rows=1360607 width=4) (actual time=128264.447..128264.447 rows=13767175 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 484003kB Buffers: shared hit=692085 read=604587 dirtied=886 written=6783 -> HashAggregate (cost=982101.73..995707.80 rows=1360607 width=4) (actual time=115476.483..124646.257 rows=13767175 loops=1) Buffers: shared hit=692085 read=604587 dirtied=886 written=6783 -> Index Scan using lineitem_l_orderkey_idx_part1 on lineitem (cost=0.00..931715.07 rows=20154663 width=4) (actual time=0.227..77303.433 rows=37965693 loops=1) Buffers: shared hit=692085 read=604587 dirtied=886 written=6783 Total runtime: 146752.175 ms (23 rows) COMMIT; COMMIT