BEGIN; BEGIN EXPLAIN select o_orderpriority, count(*) as order_count from orders where o_orderdate >= date '1997-08-01' and o_orderdate < cast(date '1997-08-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 -------------------------------------------------------------------------------------------------------------------------------------- Finalize GroupAggregate (cost=514691.32..514740.62 rows=5 width=24) Group Key: orders.o_orderpriority -> Gather Merge (cost=514691.32..514740.52 rows=10 width=24) Workers Planned: 2 -> Partial GroupAggregate (cost=513691.30..513739.34 rows=5 width=24) Group Key: orders.o_orderpriority -> Sort (cost=513691.30..513707.30 rows=6399 width=16) Sort Key: orders.o_orderpriority -> Nested Loop Semi Join (cost=0.56..513286.77 rows=6399 width=16) -> Parallel Seq Scan on orders (cost=0.00..361798.43 rows=236590 width=24) Filter: ((o_orderdate >= '1997-08-01'::date) AND (o_orderdate < '1997-11-01'::date)) -> Index Only Scan using lineitem_l_orderkey_l_suppkey_idx on lineitem (cost=0.56..4.14 rows=49 width=8) Index Cond: (l_orderkey = orders.o_orderkey) (13 rows) COMMIT; COMMIT